Skip to content

Fall back to the default when an environment variable cannot be read - #706

Open
SonnyRR wants to merge 2 commits into
Fallout-build:developfrom
SonnyRR:fix/705-host-env-collision
Open

SonnyRR wants to merge 2 commits into
Fallout-build:developfrom
SonnyRR:fix/705-host-env-collision

Conversation

@SonnyRR

@SonnyRR SonnyRR commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

An environment variable the build cannot read now falls back to the default instead of aborting the process. The FALLOUT_ prefix documented in the parameters page now works.

What changed

  • An unusable environment value reports a warning on standard error and uses the default for that parameter, instead of throwing. Built-in parameters resolve inside FalloutBuild's static constructor, so throwing there killed the process before any target ran.
  • Warnings go to standard error rather than Serilog, because Serilog is not configured yet at that point. This also makes the existing "multiple values are provided" warning visible, which it never was.
  • FALLOUT_ and NUKE_ prefixed names are matched before the bare parameter name.
  • Documented the precedence and the new failure behaviour on the parameters page.

Why the prefixes are matched first

The bare match is case-insensitive, so on Unix the HOST variable matches the Host parameter. If the bare match ran first it would always shadow FALLOUT_HOST, and the documented prefix would have no effect on the parameter that needs it most.

This also fixes an explicit override being dropped. With both HOST and NUKE_HOST set, both were collected as candidates, the resolver saw more than one, and it fell back to the default.

No behaviour is removed

Every environment variable spelling that resolved before still resolves: Host=, host= in lower case, NUKE_HOST=, --host, and the bare fuzzy match. Nothing about matching was narrowed, so the change is identical on Windows, macOS and Linux.

One case changes: a FALLOUT_* variable that is set today and ignored will start taking effect. This is unavoidable, because HOST and Host are the same string under case-insensitive comparison, so a bare match would always shadow the prefix.

Verification

The two commits are separable. The first fixes the crash on its own; the second adds the FALLOUT_ prefix and the precedence rule.

Closes #705
Fixes #457

A parameter value the build could not parse used to abort the process through
Assert.Fail. Built-in parameters are resolved inside FalloutBuild's static
constructor, so the exception escaped before any target ran and before the
consumer had a chance to handle it.

The standard Unix HOST variable made this routine. Every zsh user has HOST
exported, and Fallout reads it as the value for the Host parameter, so builds
failed at startup with "Value 'M2' could not be converted to 'Host'". The same
happened for any unusable value, for example VERBOSITY set to something that is
not a verbosity level.

Parameters now report a warning and use the default instead. Warnings go to
standard error rather than Serilog, because Serilog is not configured yet at
this point in startup. That also makes the existing "multiple values are
provided" warning visible, which it never was.

Fixes Fallout-build#705.
The documentation states that parameters can be set with a FALLOUT_ prefix,
but the resolver only ever looked for NUKE_. A FALLOUT_ variable was ignored.

The resolver now matches FALLOUT_ and NUKE_ before the bare parameter name.
Prefixed names come first because the bare match is case-insensitive, so on
Unix the HOST variable matches the Host parameter and would otherwise shadow
FALLOUT_HOST.

This also fixes a case where an explicit override was dropped. With HOST and
NUKE_HOST both set, both were collected as candidates, the resolver saw more
than one, and it fell back to the default. The prefixed value now wins.

Fixes Fallout-build#457.
@SonnyRR
SonnyRR marked this pull request as ready for review October 10, 2026 08:46
@SonnyRR
SonnyRR requested a review from a team as a code owner October 10, 2026 08:46
@dennisdoomen dennisdoomen added enhancement New feature or request target/vCurrent Targets the current version labels Oct 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request target/vCurrent Targets the current version

Projects

None yet

2 participants