Repository navigation
fix(claude-ops): route large jq payloads via --slurpfile, not argv - #1380
Conversation
…of argv fleet-state.sh embedded catalog/installed/enabled JSON blobs as literal `jq --argjson` command-line arguments. For a marketplace catalog large enough (confirmed against a real 273-plugin catalog), the serialized JSON exceeded the platform/shell's argv-length ceiling and jq crashed with "Argument list too long" before emitting anything, silently dropping that marketplace from sync/audit/converge. Confirmed on Windows Git Bash/MSYS jq, but the underlying ceiling is real everywhere. Every affected call site now writes its payload to a temp file and passes --slurpfile instead of --argjson, so catalog size never determines whether jq can run. Two follow-on defects surfaced during verification and are fixed in the same change: temp files are cleaned up via a single per-run directory (a subshell-safe pattern, since each writer call runs inside a $(...) subshell) rather than an array that would silently fail to track them, and an empty payload (from a prior read of malformed source JSON) writes a deliberately-invalid sentinel so jq's own parser still fails loud at the call site, preserving the pre-fix fail-loud behavior instead of silently degrading the report to null fields. Closes #1336 Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Claude finished @kyle-sexton's task in 4m 21s —— View job Code Review
Overall: well-implemented fix — correct root cause, clean solution, thorough tests. A few minor observations below, none blocking.
|
|
Claude finished @kyle-sexton's task in 2m 23s —— View job Security Review — PR #1380
No security issues found. I reviewed all four changed files ( Temp file handling (primary change surface) The temp directory is created with Exit-trap cleanup
Command / argument injection
Data sensitivity in temp files The data routed through temp files is Sentinel for empty payloads The
The variable is set unconditionally on line 134, overwriting any ambient environment value of the same name before the trap is registered. An attacker-controlled pre-existing |
Closes #1336
Summary
fleet-state.sh(claude-opspluginsskill) embedded catalog/installed/enabled JSON blobs asliteral
jq --argjsoncommand-line arguments; a large enough marketplace catalog (confirmedagainst a real 273-plugin catalog) exceeded the platform/shell's argv-length ceiling and jq
crashed with
Argument list too longbefore emitting anything, silently dropping thatmarketplace from
sync/audit/converge. Confirmed on Windows Git Bash/MSYS jq, but theunderlying ceiling is a real OS
ARG_MAXlimit everywhere, just reached sooner there.--slurpfileinsteadof
--argjson, so catalog size never determines whether a marketplace can be synced. Only thefixed-size boolean
--argjsonuses (au/ci/autoUpdate) remain untouched.EXITtrap, not an array —each writer call runs inside a
$(...)subshell, so an array append there would silentlyvanish on return.
settings.json) used to make the affected--argjsonfail loudimmediately;
--slurpfileinstead tolerates a genuinely empty payload as "zero JSON values"and would have silently degraded the report to
nullfields. The writer now emits adeliberately-invalid sentinel for an empty payload so jq's own parser still errors at the call
site, preserving the pre-fix fail-loud behavior.
claude-opsto0.19.3with a matchingCHANGELOG.mdentry.Test plan
fleet-state.test.sh(31 cases, 0 failed), including two new cases added by this PR:Argument list too long, exit 0, and full non-truncated output (catalog/installed/missing_*arrays all correctly sized, a spot-checked
enabledentry correct).user_settings.jsoncase — asserts the fix still fails loud (nonzero exit), notsilently degraded.
--argjsoncount stays at the fixed booleans-onlytotal, so a future edit can't silently reintroduce a large-payload
--argjsoncall site.HEADviagit archiveand ran it against the same synthetic 500-plugin fixture — confirmed
Argument list too longbefore this fix, confirmed clean success after.
after a normal run — no leaked files).
shellcheckclean onfleet-state.sh.Related
N/A
🤖 Generated with Claude Code