Skip to content

The Build Mode Environment Variable Needs Validation #1709

@NiranjanKumar001

Description

@NiranjanKumar001

What's happening?

Right now, when someone sets the LINGO_BUILD_MODE environment variable to control how translations work during a build, there’s no validation of the value. That means even if they accidentally type something incorrect like LINGO_BUILD_MODE=production or LINGO_BUILD_MODE=dev (or any random typo)—the system still accepts it.
As a result, the build can behave in unexpected or confusing ways.

In reality, only two values should be allowed: "translate" and "cache-only". However, the code doesn’t currently check for this, so invalid values slip through without any warning.

Exact Reproduction Steps

1.LINGO_BUILD_MODE=invalid pnpm build
or
2.LINGO_BUILD_MODE=production pnpm build
or
3.LINGO_BUILD_MODE=dev pnpm build

Expected

Error: Invalid LINGO_BUILD_MODE: "invalid". Must be "translate" or "cache-only"

Actual

Right now, if you set LINGO_BUILD_MODE to an invalid value (for example, LINGO_BUILD_MODE=invalid), the build system doesn’t complain at all. It doesn’t warn you or say, “Hey, that’s not a valid option.”

Instead, this is what happens:

The build starts normally, so everything looks fine at first

It even prints the invalid value, like Build mode: invalid (as shown in the screenshot)

The build keeps running for a while

Eventually, it crashes with a confusing error message that doesn’t clearly explain the real problem

So if you accidentally type something like LINGO_BUILD_MODE=prod instead of cache-only, you won’t realize your mistake right away. You’ll sit there thinking the build is working, until it suddenly fails with errors about missing API keys or translation issues. Only then do you have to go back and figure out what went wrong.

This is especially frustrating because the actual fix is trivial—just correcting a typo. But instead of pointing you to the real issue, the error messages send you down a long debugging path for something that should have been caught immediately.

Screenshots/Videos

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions