Skip to content

fix: avoid jq argument limits in fleet snapshots - #5122

Open
dutopy wants to merge 2 commits into
kunchenguid:mainfrom
dutopy:fm/fix-fleet-snapshot-jq-arglist
Open

dutopy wants to merge 2 commits into
kunchenguid:mainfrom
dutopy:fm/fix-fleet-snapshot-jq-arglist

Conversation

@dutopy

@dutopy dutopy commented Sep 21, 2026 •

Copy link
Copy Markdown

Intent

The fleet snapshot (bin/fm-fleet-snapshot.sh) fails with Argument list too long as the number of records grows: on 2026-09-18 a session start printed bin/fm-fleet-snapshot.sh: line 1978: /usr/bin/jq: Argument list too long, and on 2026-09-21 the same error reappeared during a contributions read. The snapshot must produce identical output without ever passing an unbounded argument list to jq.

What Changed

  • Stage contribution backlog and task JSON in temporary files instead of passing unbounded data through jq arguments.
  • Add regression coverage verifying contribution snapshots preserve backlogs larger than ARG_MAX without truncation.

Risk Assessment

⚠️ Medium: The file-based jq transport is a straightforward durable fix, but the unrelated removal of broad behavioral coverage should be reviewed before merging.

Testing

The targeted behavior suite passed, and live isolated CLI runs reproduced the base commit's Argument list too long failure while confirming the changed product emits valid, complete oversized backlog and task output with unchanged normal output.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Generate a normal contribution snapshot and preserve the existing output exactly ✅ pass live The live-validation artifact records a byte-for-byte match with the base output, SHA-256 2284111320cecdd547be2932a40592852ece99935a3875466beac287efc9ffab.
Generate a contribution snapshot from a backlog larger than ARG_MAX without losing or mangling records ✅ pass live The live-validation artifact shows a 5,137,010-byte backlog versus ARG_MAX 2,097,152; current output was valid JSON containing all 11,000 unique records from rec-000001 through rec-011000. The his…
Generate a contribution snapshot when the task document itself exceeds ARG_MAX ✅ pass live The live-validation artifact shows valid 2,404,750-byte current output with all 24 unique task records and complete payloads; the historical executable reproduced Argument list too long.
Evidence: Live fleet snapshot regression and compatibility evidence

Source: Live fleet snapshot regression and compatibility evidence

Public CLI exercised: bin/fm-fleet-snapshot.sh --contribution-input
Small-output compatibility: exact byte-for-byte match with base commit
small_output_sha256=2284111320cecdd547be2932a40592852ece99935a3875466beac287efc9ffab
small_backlog_records=3
small_tasks=1
ARG_MAX=2097152
large_backlog_bytes=5137010
large_backlog_exceeds_ARG_MAX=true
historical_base_exit=0
historical_base_output_bytes=0
historical_base_valid_json=false
historical_base_stderr=bin/.fm-fleet-snapshot-base-live-test.sh: line 1991: /usr/bin/jq: Argument list too long 
current_exit=0
current_stderr=
current_output_bytes=20823315
current_valid_json=true
current_record_count=11000
current_unique_record_ids=11000
current_first_id=rec-000001
current_last_id=rec-011000
current_tasks=1

Large contribution-task transport scenario
ARG_MAX=2097152
historical_base_exit=0
historical_base_valid_json=false
historical_base_stderr=bin/.fm-fleet-snapshot-base-live-test.sh: line 1991: /usr/bin/jq: Argument list too long 
current_exit=0
current_stderr=
current_output_bytes=2404750
current_output_exceeds_ARG_MAX=true
current_task_count=24
current_unique_task_ids=24
current_first_task=task-01
current_last_task=task-24
current_task_payloads_complete=true

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 warning
  • ⚠️ tests/fm-fleet-snapshot-view.test.sh:1193 - The change removes the existing test_fixture_snapshot_json invocation, leaving that behavioral test defined but never run. This drops unrelated coverage of the default snapshot’s task ordering, state, PR, backlog, report, and endpoint output while the intent requires unchanged output. Restore the invocation unless this coverage reduction was explicitly intended.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Generate a normal contribution snapshot and preserve the existing output exactly ✅ pass live The live-validation artifact records a byte-for-byte match with the base output, SHA-256 2284111320cecdd547be2932a40592852ece99935a3875466beac287efc9ffab.
Generate a contribution snapshot from a backlog larger than ARG_MAX without losing or mangling records ✅ pass live The live-validation artifact shows a 5,137,010-byte backlog versus ARG_MAX 2,097,152; current output was valid JSON containing all 11,000 unique records from rec-000001 through rec-011000. The his…
Generate a contribution snapshot when the task document itself exceeds ARG_MAX ✅ pass live The live-validation artifact shows valid 2,404,750-byte current output with all 24 unique task records and complete payloads; the historical executable reproduced Argument list too long.
  • bash tests/fm-fleet-snapshot-view.test.sh
  • FM_HOME=<isolated-home> bin/fm-fleet-snapshot.sh --contribution-input with a 5,137,010-byte backlog containing 11,000 records
  • FM_HOME=<isolated-home> bin/fm-fleet-snapshot.sh --contribution-input with contribution-task output exceeding ARG_MAX
  • Byte-for-byte comparison of normal contribution output against base commit 631bc26d7b08b57e724f08a1734cc2eb2a0abf52
  • Historical regression reproduction using the base executable against both oversized inputs
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

fm-fleet-snapshot --contribution-input passed the whole backlog JSON and
contribution task list to jq as --argjson arguments, so record growth
eventually exceeded ARG_MAX and failed with "Argument list too long"
exactly when the snapshot mattered most. Stage both documents in the
temporary transport directory and read them with --slurpfile, matching
the main snapshot path. Output shape is unchanged.

Regression: a generated backlog exceeding ARG_MAX must produce complete,
valid contribution input with every record present.
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.

1 participant