fix(start-sdk): drop undefined keys when writing an env file model - #3874
Merged
Conversation
dr-bonez
previously approved these changes
Sep 2, 2026
`merge(effects, { KEY: undefined })` removes the key everywhere except
`FileHelper.env`, which rendered it through a template literal and wrote the
string `KEY=undefined`. `fileMerge` leaves the key present with an undefined
value and `z.deepLoose` keeps it, so whether it survives has been up to each
writer: JSON, YAML, TOML and the XML builder drop it natively and `ini` was
filtered explicitly, leaving env alone in serializing the word.
Filter in one place both `write` and `merge` render through, so the contract
holds for every format rather than five of six by accident, and merge's
dirty-check compares the same bytes it writes. The ini writer's own
`filterUndefined` call is now redundant.
Live instance of the bug: bitcoin-explorer-startos writes
`BTCEXP_REDIS_URL: input.redis ? redisUrl : undefined`, so turning Redis off
handed btc-rpc-explorer a URL of "undefined" while the shape's `.catch()`
reported the real URL back to the package, which then believed Redis was on.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
helix-nine
force-pushed
the
fix/file-helper-env-undefined
branch
from
September 2, 2026 21:15
1d09068 to
4d06e29
Compare
dr-bonez
approved these changes
Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
merge(effects, { KEY: undefined })removes the key from a file model — except onFileHelper.env, which writes the literalKEY=undefined.What's happening
fileMergeleaves the key present with an undefined value, andz.deepLoose(shape).parsekeeps it, so whether it survives to disk has been up to each writer:jsonJSON.stringifyomits ityaml/toml/xmliniINI.stringify(filterUndefined(inData)), explicitlyenvObject.entries(inData).map(([k, v]) => \${k}=${v}`)` stringifies it to the wordSame shape, same file,
merge(effects, { K: undefined })on 2.0.9:A key simply absent from the merge object is a correct no-op in all six.
The fix
Filter in the one place
writeandmergeboth render through, rather than per writer — the contract then holds for every format instead of five of six by accident, andmerge's dirty-check compares the same bytes it goes on to write. Theiniwriter's ownfilterUndefinedcall becomes redundant and is removed.Why it matters
FileHelper.envis rare in the fleet — three packages across both registries — which is why this held up unnoticed. One of them hits it:bitcoin-explorer-startoswritesso turning Redis off in its Configure action writes
BTCEXP_REDIS_URL=undefined. btc-rpc-explorer then gets a Redis URL of"undefined", while the shape's.catch(redisUrl)masks the bad value on read — so the package's own guard still reports Redis as enabled and the setting silently doesn't take. Filed as an issue on that repo.Tests
lib/test/fileHelper.merge.test.tscovers both directions across the five text formats — a key merged asundefinedis removed, a key the merge doesn't name is left alone. Verified it fails on the env case without the fix (1 failed, 9 passed) and passes with it.Full suite on this branch:
9 passed, 117 tests.