Skip to content

path, context: a refusal in --json mode keeps its prose (#1911) - #1912

Merged
swapnilpaliwal-sd merged 1 commit into
devfrom
fix/path-json-refusal
Oct 10, 2026
Merged

swapnilpaliwal-sd merged 1 commit into
devfrom
fix/path-json-refusal

Conversation

@swapnilpaliwal-sd

@swapnilpaliwal-sd swapnilpaliwal-sd commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1911 — found by the 0.1.9 cross-platform release check.

Symptom. axiomcode path main NoSuchName printed nothing and exited 2. 0.1.9's front door asks every verb for --json, and in that mode a refusal was lost. A normal path query was unaffected.

Cause. In --json mode axiomcode-path (and axiomcode-context) run the answer inside contextlib.redirect_stdout. A refusal leaves through die() → SystemExit, which escaped the with block, so neither the JSON document nor the prose it carries was printed.

Fix. SystemExit is caught inside the redirect and its exit code kept; the JSON is printed with the refusal as its prose, and the exit code stays 2.

Case tests/cases/python/a-refused-endpoint-is-said: the front-door check (AXIOMCODE_FRONT=1) fails on the base, 2/3 → 3/3 after; control: path main helper still answers.

Branched from 0.1.9, so until the release PR (#1905) merges, this PR's diff also shows the 0.1.9 commits; its own change is one commit (db26884).

The front door asks every verb for --json. In that mode path and context run the
answer inside redirect_stdout; a refusal (an endpoint nothing declares) leaves through
die() -> SystemExit, which escaped the with-block, so neither the JSON nor its prose was
printed: 'axiomcode path main NoSuchName' answered nothing at all, rc 2.

SystemExit is caught inside the redirect and its code kept, so the document is printed
with the refusal as its prose.

Case a-refused-endpoint-is-said: the front-door check fails on the base (2/3), all pass
after; control: a declared pair still answers.

Co-authored-by: axiomcode-bot[bot] <334110751+axiomcode-bot[bot]@users.noreply.github.com>
@swapnilpaliwal-sd
swapnilpaliwal-sd merged commit 1445221 into dev Oct 10, 2026
12 checks passed
@swapnilpaliwal-sd
swapnilpaliwal-sd deleted the fix/path-json-refusal branch October 10, 2026 23:24
@swapnilpaliwal-sd swapnilpaliwal-sd changed the title path, context: a refusal in --json mode keeps its prose (#1911) path, context: a refusal keeps its prose in --json (#1911); the export lock does not Ctrl-C its holder on Windows (#1916) Oct 10, 2026
@swapnilpaliwal-sd swapnilpaliwal-sd changed the title path, context: a refusal keeps its prose in --json (#1911); the export lock does not Ctrl-C its holder on Windows (#1916) path, context: a refusal in --json mode keeps its prose (#1911) Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

path: an unknown endpoint prints nothing (exit 2) through the front door; the refusal is lost in --json mode

1 participant