Name the variable when a GRAPHARC_* env value cannot be coerced - #33
Merged
Conversation
A non-numeric GRAPHARC_MAX_TOKENS crashed grapharc run with a raw ValueError traceback, exit 1 and an empty stdout — so a CI gate on --check-only read "topology refused" when the truth was "someone exported GRAPHARC_MAX_TOKENS=unlimited in the job environment". plan did not traceback, but its broad handler relabelled the failure "could not build the plan: invalid literal…", pointing the reader at the model rather than their shell. Settings.resolve now wraps the env coercion and raises ConfigError with the wording the file layer already uses for the same mistake: GRAPHARC_MAX_TOKENS must be int, got 'unlimited'. An exported variable is invisible on the command line, which is exactly why the error must say which one it was. Every caller already catches ConfigError and routes it through fail(...) with exit 2, so in --json mode the failure is one parseable document on stdout with stderr empty — nothing else needed touching. Fixes #16 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
What was wrong
A
GRAPHARC_*environment variable that could not be coerced to its key's type crashedgrapharc runwith a rawValueErrortraceback — exit 1 (the "ran and the answer was negative" code), empty stdout, traceback on stderr — breaking the documented--jsoncontract that a failure is one parseable document on stdout and exit 2 means "could not run at all". A CI gate on--check-onlywould read that as "topology refused" when the truth wasGRAPHARC_MAX_TOKENS=unlimitedexported in the job environment.grapharc planswallowed theValueErrorin its broad handler and mislabelled itcould not build the plan: invalid literal for int() with base 10: 'abc'— naming neither the variable nor the shell as the place to look.The fix
Settings.resolve(grapharc/cli/config.py) now wraps the env coercion and raisesConfigErroronValueError, mirroring the wording the file layer already uses five lines down for the same mistake:Nothing else needed touching: every command that resolves settings already catches
ConfigErrorand routes it throughfail(...)with exit 2, sorun --jsonnow emits a single"ok": falsedocument on stdout with stderr empty, andplanreports the named message instead of "could not build the plan".Tests
Three new tests beside the existing config tests in
tests/test_config.py, all red against the unfixed source:resolveon an int key withGRAPHARC_MAX_TOKENS=unlimitedraisesConfigErrornaming the variable, the expected type and the given valuegrapharc run … --check-only --jsonunder that environment exits 2 with one"ok": falsedocument on stdout and empty stderrgrapharc plan --jsonunderGRAPHARC_MAX_ROUNDS=abcreports the named message, not the planner-flavoured oneValid env values keep working and still report
"env"in the provenance sources (pinned by the existing precedence tests). No README/cookbook output changed.uv run pytestgreen,uv run ruff check .clean.Out of scope, per the issue: precedence order, empty-string env handling, new
KEYS, bool handling.Fixes #16
🤖 Generated with Claude Code