From a2fa9a2ce7549323574f2cae8fd53dbe92d0dbf6 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 30 Apr 2026 19:57:34 -0500 Subject: [PATCH] =?UTF-8?q?scripts/scrum=5Freview:=20pipe=20diff=20via=20t?= =?UTF-8?q?emp=20files=20=E2=80=94=20fixes=20argv=20overflow=20on=20large?= =?UTF-8?q?=20bundles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `jq --arg` and `curl --data-binary @-` both read stdin/argv-bound buffers. Diffs >~128KB blow past the kernel's argv limit even when piped via stdin (because we still build `body` as a shell variable first, then feed it to curl). Voice-ai full bundle was 156K and hit it. Switch to writing user/system/body to mktemp files, jq reads via --rawfile, curl reads via @file. Same on-the-wire shape, no argv involvement. Cleanup with rm at the end. Co-Authored-By: Claude Opus 4.7 (1M context) --- scripts/scrum_review.sh | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/scrum_review.sh b/scripts/scrum_review.sh index 845fe1e..52bebe3 100755 --- a/scripts/scrum_review.sh +++ b/scripts/scrum_review.sh @@ -75,20 +75,27 @@ run_review() { \`\`\`diff $DIFF_CONTENT \`\`\`" - local body - body=$(jq -n --arg model "$model" --arg sys "$SYSTEM" --arg user "$user" \ - '{model:$model, max_tokens:4096, messages:[{role:"system",content:$sys},{role:"user",content:$user}]}') printf " %-6s %s ... " "$short" "$model" local t0=$SECONDS local status - # Pipe the body via stdin (`-d @-`) — large diffs (>~128KB) blow - # past the kernel's argv limit when passed via `--data `. - # Phase A+B was 128875 bytes and hit "Argument list too long" until - # this fix. - status=$(printf '%s' "$body" | curl -sS -o /tmp/scrum_resp.json -w '%{http_code}' --max-time 240 \ + + # Build the body via temp files — both jq's --arg AND curl's + # --data run into the kernel's argv limit (~128KB) when the diff + # is large. Voice-ai full bundle was 156K and hit it twice. + # Piping through files (and using --rawfile for jq) sidesteps both. + local body_file user_file sys_file + body_file=$(mktemp); user_file=$(mktemp); sys_file=$(mktemp) + printf '%s' "$user" > "$user_file" + printf '%s' "$SYSTEM" > "$sys_file" + jq -n --arg model "$model" --rawfile sys "$sys_file" --rawfile user "$user_file" \ + '{model:$model, max_tokens:4096, messages:[{role:"system",content:$sys},{role:"user",content:$user}]}' \ + > "$body_file" + + status=$(curl -sS -o /tmp/scrum_resp.json -w '%{http_code}' --max-time 240 \ -X POST "$GATEWAY/v1/chat" \ -H 'Content-Type: application/json' \ - --data-binary @-) + --data-binary "@$body_file") + rm -f "$body_file" "$user_file" "$sys_file" local elapsed=$((SECONDS - t0)) if [ "$status" != "200" ]; then printf "✗ HTTP %s (%ds)\n" "$status" "$elapsed"