Repository navigation
fix: preserve JSON errors for config-local format - #985
saariuslystoned wants to merge 2 commits into
Conversation
Co-authored-by: saariuslystoned <159389674+saariuslystoned@users.noreply.github.com>
Co-authored-by: saariuslystoned <159389674+saariuslystoned@users.noreply.github.com>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. What this changesPreserve command-local JSON formatting for config show and config init errors during parsing and configuration loading. Example: Run acpx config show --format json --bogus.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains This PR fixes a current-main error-formatting gap, but its new scanner misinterprets consumed option values as format flags. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe CLI selects an error-output policy from arguments before loading configuration and parsing commands, then sends failures through the shared error formatter. flowchart TD
Arguments --> FormatDetection
FormatDetection --> OutputPolicy
Arguments --> ConfigLoading
ConfigLoading --> CommandParsing
CommandParsing --> ErrorHandler
OutputPolicy --> ErrorHandler
ErrorHandler --> OutputStreams
Technical reviewBest possible solution: Use a forward, value-aware config-local scan that preserves the last valid format and existing root precedence. Do we have a high-confidence way to reproduce the issue? Current-main source explains the reported missing JSON errors, and supplied built-CLI captures demonstrate them; the consumed-value defect is source-verifiable without executing target code. Is this the best way to solve the issue? Extending the existing early-output owner is appropriate, but scanning must respect required-option consumption rather than treating every token as an independent flag. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against af67042fac73. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 8, 2026, 12:05 AM ET / 05:05 UTC. |
What Problem This Solves
Fixes:
config showandconfig initcan emit only human-readable errors despite their command-local--format jsonwhen argument parsing or initial configuration loading fails.User Impact
Scripted callers receive the existing JSON-RPC error envelope for these failures, with the existing usage exit 2 or configuration-error exit 1. A later invalid or missing repeated format value preserves the last valid format, matching global-flag error handling. Explicit global precedence, help, successful config operations and
--boundaries retain their behavior.Why This Change Was Made
Early error handling now recognizes the existing local format option for
config showandconfig init. It does not introduce flags, a schema or adapter behavior. The original repair and the repeated-format follow-up are included in this branch.Evidence
Current-head local checks and GitHub CI passed. Fresh comprehensive independent P0–P3 review of the entire exact base/head branch is scoped-clean with zero findings. Hosted ClawSweeper review remains pending before final handoff. The static reviewer assessed the supplied diff and reviewed tests without executing them; actual CLI and full-test evidence is separate below. The incremental native review covers only the follow-up and is retained separately.
Exact base:
af67042fac736e8c1d0cd9dd4b8057fcee85d46d. Exact head:884063b1897d405db269126d17f2870c49927fe7(two commits, three changed files).Independent proof runs the actual built
dist/cli.json Linux Node 26.13.0 with synthetic isolated HOME, cwd and PATH, closed stdin and bounded subprocess timeouts. No provider requests or credentials are used.Original frozen entrypoint fixture: 14/14 passed; repeated-format fixture: 24/24 passed. Twelve additional independent entrypoint cases passed, including positional controls, malformed global configuration and successful init artifact/readback. The actual last-valid-format/quiet/global-precedence/separator controls remain in those fixtures.
pnpm run check: PASS on exact head: 3,189 tests, 3,173 passed, 16 skipped, zero failed/cancelled; all 247 separate coverage cases and declared 85% coverage gates passed. Coverage measures the declared flows/runtime source set, not the whole repository.pnpm run check:docsand explicit changed-Changelog formatting/Markdown lint passed.pnpm run mutate: PASS, mutation score 92.07% (441 killed, 38 survived, 0 timeout/errors; configured unchangedsrc/cli/flags.tstarget, not coverage of the early-error detector).Commands:
The prior-head full check failed the wrapper-exited conformance test with
initialize failed: The operation was aborted. The identical failure independently reproduces on unchanged public base (two passes, then one failure); implicated test/runner/source/lock blobs are identical. Current-head focused conformance passed all 15 cases. That historical failure is retained separately and is not represented as a passing run or an F034 fix. The native broad run also failed/incomplete and is not claimed green.Actual built-CLI captures
These captures preserve subprocess streams and exits. Disposable paths are replaced by
/FIXTUREor/CHECKOUT. Usage errors retain existing human stderr alongside JSON stdout; no strict-JSON stderr claim is made. Source inspection occurred, so this is independent source-known entrypoint validation.Base: config show local JSON usage error
{ "argv": [ "--cwd", "/FIXTURE/good", "config", "show", "--format", "json", "--unknown-fixture-flag" ], "exit": 2, "stdout": "", "stderr": "error: unknown option '--unknown-fixture-flag'\n\nUsage: acpx config show [options]\n\nShow resolved config\n\nOptions:\n --format <fmt> Output format: text, json, quiet\n -h, --help display help for command\nerror: unknown option '--unknown-fixture-flag'\n", "init_target_exists": false }Candidate: same usage-error owning path
{ "argv": [ "config", "show", "--format", "json", "--bogus" ], "case": "usage-local", "exit": 2, "stdout": "{\"jsonrpc\":\"2.0\",\"id\":null,\"error\":{\"code\":-32602,\"message\":\"error: unknown option '--bogus'\",\"data\":{\"acpxCode\":\"USAGE\",\"origin\":\"cli\",\"sessionId\":\"unknown\"}}}\n", "stderr": "error: unknown option '--bogus'\n\nUsage: acpx config show [options]\n\nShow resolved config\n\nOptions:\n --format <fmt> Output format: text, json, quiet\n -h, --help display help for command\n", "configUnchanged": true }Candidate: early malformed configuration error
{ "argv": [ "config", "show", "--format", "json" ], "case": "malformed-config-local", "exit": 1, "stdout": "{\"jsonrpc\":\"2.0\",\"id\":null,\"error\":{\"code\":-32603,\"message\":\"Invalid JSON in /FIXTURE/home/.acpx/config.json: Expected property name or '}' in JSON at position 1 (line 1 column 2)\",\"data\":{\"acpxCode\":\"RUNTIME\",\"origin\":\"cli\",\"sessionId\":\"unknown\"}}}\n", "stderr": "", "configUnchanged": true }Candidate: valid JSON then missing repeated format on init
{ "argv": [ "config", "init", "--format", "json", "--format" ], "code": 2, "stdout": "{\"jsonrpc\":\"2.0\",\"id\":null,\"error\":{\"code\":-32602,\"message\":\"error: option '--format <fmt>' argument missing\",\"data\":{\"acpxCode\":\"USAGE\",\"origin\":\"cli\",\"sessionId\":\"unknown\"}}}\n", "stderr": "error: option '--format <fmt>' argument missing\n\nUsage: acpx config init [options]\n\nCreate global config template\n\nOptions:\n --format <fmt> Output format: text, json, quiet\n -h, --help display help for command\n", "configWritten": false }AI-assisted contribution: RoboClaw implementation; Codex independent reproduction and validation. Maintainer edits are enabled. Human approval is required for merge; no merge is requested or performed.