From f9101a1f8e84ae59e45a7c16b0de10823743f1bb Mon Sep 17 00:00:00 2001 From: Benjamin Borbe Date: Mon, 10 Aug 2026 14:07:48 +0200 Subject: [PATCH] fix: ast-grep-runner: use --slurpfile to avoid ARG_MAX on large payloads --- CHANGELOG.md | 4 ++++ scripts/ast-grep-runner.sh | 17 ++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 301b762..56e6cdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ Please choose versions by [Semantic Versioning](http://semver.org/). * MINOR version when you add functionality in a backwards-compatible manner, and * PATCH version when you make backwards-compatible bug fixes. +## Unreleased + +- fix: ast-grep-runner: pass finding payloads to `jq` via `--slurpfile` instead of `--argjson`, fixing `Argument list too long` on large result sets. Both sites moved: the per-owner merge and the final assembly. Payloads were being read out of files into shell variables and pushed back through `argv`; `jq` now reads the files directly, so payload size is irrelevant. Scales with finding count and matched-text size, not file count — reproduced with 1,956 findings from 429 files, which previously produced an **empty output file and exit 0**. + ## v0.42.0 - feat: golden set covers `curated-1` — 155 entries over 20 PRs, up from 42 over 5. All 115 unmatched findings from the curated-1 Opus pass were adjudicated individually: 113 new entries, plus 2 findings that turned out to be an issue the set already held, re-reported in different words, where the existing key was relaxed rather than duplicated. One issue, one entry — a duplicate is what inflated recall to a spurious `1.000` in `v0.37.0` diff --git a/scripts/ast-grep-runner.sh b/scripts/ast-grep-runner.sh index 84e7be2..e329e9c 100755 --- a/scripts/ast-grep-runner.sh +++ b/scripts/ast-grep-runner.sh @@ -297,20 +297,19 @@ for owner_file in "$FINDINGS_DIR"/*.jsonl; do # but owner names use '-' not '/', so the original name is preserved) basename_no_ext="$(basename "$owner_file" .jsonl)" owner_name="$basename_no_ext" - # Collect all findings for this owner into a JSON array - findings_array=$(jq -s '.' "$owner_file") + # Merge this owner's findings via --slurpfile, NOT --argjson. + # --argjson passes the whole payload through argv and dies with + # "Argument list too long" past ARG_MAX; --slurpfile makes jq read the + # file itself, so payload size is irrelevant. FINDINGS_JSON_TMP="$TMPDIR_WORK/fbo_tmp.json" - jq --arg o "$owner_name" --argjson arr "$findings_array" \ + jq --arg o "$owner_name" --slurpfile arr "$owner_file" \ '. + {($o): $arr}' "$FINDINGS_JSON" > "$FINDINGS_JSON_TMP" && mv "$FINDINGS_JSON_TMP" "$FINDINGS_JSON" done -ERRORS_JSON="$(cat "$ERRORS_FILE")" -FINDINGS_OBJ="$(cat "$FINDINGS_JSON")" - jq -n \ --argjson yamls_run "$YAMLS_RUN" \ --argjson findings_count "$FINDINGS_COUNT" \ --argjson elapsed_ms "$ELAPSED" \ - --argjson findings_by_owner "$FINDINGS_OBJ" \ - --argjson errors "$ERRORS_JSON" \ - '{stats:{yamls_run:$yamls_run, findings_count:$findings_count, elapsed_ms:$elapsed_ms}, findings_by_owner:$findings_by_owner, errors:$errors}' + --slurpfile findings_by_owner_arr "$FINDINGS_JSON" \ + --slurpfile errors_arr "$ERRORS_FILE" \ + '{stats:{yamls_run:$yamls_run, findings_count:$findings_count, elapsed_ms:$elapsed_ms}, findings_by_owner:$findings_by_owner_arr[0], errors:$errors_arr[0]}'