Repository navigation
fix(cli): --variables-file reads the file instead of failing with io.readFile is not a function - #6591
fix(cli): --variables-file reads the file instead of failing with io.readFile is not a function#6591cathrynlavery wants to merge 3 commits into
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
Reviewed at 3c6118866a87f0414067967dfa222b8ac5f6d392.
The explicit nullish defaults fix undefined injected file readers. Please rebase onto main before I approve the resulting tree.
vitest run jsonFlag.test.ts --configLoader runner: 4 passed. No full integration run is claimed.
Need: yes · Size: ok · Reuse: existing helper and dispatch paths · Simpler: keep the focused fix · Structure: fine
Risk: medium - compatibility with current main.
Verdict: COMMENT
Reasoning: The branch currently conflicts with main; I will review the resolved delta after a rebase.
Reasoning: The explicit nullish defaults fix undefined injected file readers. Please rebase onto main before I approve the resulting tree.
|
#6831 merged the same fix, so I'm closing this one. Thanks for the review. |
What
In 0.8.209,
--variables-filefails onrender,lambda render,cloudrunandcloud render:With this change,
readJsonFlagTextuses its default reader whenever a caller passesundefinedforreadFileorreadStdin.Why
resolveVariablesArgcallsparseVariablesArg(inline, filePath)without readers, andparseVariablesArgforwards{ readFile, readStdin }, bothundefined, toreadJsonFlagText. There,{ ...defaultIO, ...partialIo }copies theundefinedvalues over the defaults. Every existing test injects a reader, so none of them reached the default.To reproduce on 0.8.209, in any project:
Related work
Regression from #6518.
How
readJsonFlagTextpicks each reader with??instead of spreadingpartialIo, so an explicitundefinedkeeps the default. The fix sits in the shared reader, so any other caller that forwards optional readers gets it too.Test plan
parseVariablesArg(undefined, <path>)with no reader reads a real file. On main it fails withcause: "io.readFile is not a function".data-var-text="title", rendered with--variables-file vars.json --strict-variables. 0.8.209 exits 1 with the error above. This branch renders, and the frame shows the title from the file.packages/cli, and thevariables,jsonFlagandmedia-treatmenttests pass (56). In the full CLI suite, the failures on this Mac also fail on main (ffmpeg track decode, whisper/sherpa runtime, Chromium WebGL sweep), apart from two file-watcher timing tests that pass when run alone.check-comment-citationsandcomment-ratchetpass.