fix(org-status): avoid ARG_MAX crash with 200+ open PRs - #258
Conversation
Passing a growing JSON array via `jq --argjson` exceeds the Linux kernel's ARG_MAX limit (~2-3 MB) once enough PR data accumulates. The daily run hit this at 252 PRs across 8 repos (exit code 126, "Argument list too long"). Switch both the PR and issues accumulation loops to the NDJSON pattern already used in the Behind-Base Detection section: emit one compact JSON line per item into a string variable, then slurp into an array once at the end with `jq -cs '.'`. No PR/issue data ever passes through a command-line argument. Regression test (8 repos × 35 PRs = 280 synthetic PRs): - Old pattern: Argument list too long at repo 7/8 - New pattern: 280 PRs accumulated successfully Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR updates scripts/org_status.sh to prevent Linux ARG_MAX failures when aggregating large numbers of open PRs/issues across many repositories by switching from “grow a JSON array via --argjson” to an NDJSON accumulation + final slurp approach.
Changes:
- Accumulate PRs as NDJSON (one compact JSON object per line) and slurp once at the end with
jq -cs '.'. - Apply the same NDJSON pattern to the issues aggregation loop to avoid the same failure mode as issue volume grows.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request refactors scripts/org_status.sh to use NDJSON accumulation for pull requests and issues, effectively preventing ARG_MAX errors when handling large datasets. Feedback suggests applying this pattern to other sections of the script, such as merge activity and internal PR collection, for complete robustness. Additionally, the reviewer recommends using Bash here-strings (<<<) instead of echo or printf for more idiomatic and safer piping of variable content to jq.
…< style Address Gemini review on PR #258: - collect_classify_prs: replace --argjson page accumulation (all_nodes) with NDJSON pattern; protects against repos with many PR pages, not just large org totals. Also switch echo | jq to <<< throughout the function. - Merge activity: write ORG_MERGES/PERSONAL_MERGES to DATA_DIR/merges.json via printf (bash builtin, no exec, no ARG_MAX) so MERGE_DAILY and MERGE_BY_REPO_DAY read from a file descriptor instead of --argjson args. - All remaining echo "$x" | jq and printf | jq replaced with <<< herestrings as suggested (more idiomatic, avoids echo flag interpretation edge case). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
|
* fix(org-status): avoid ARG_MAX crash when org has 200+ open PRs Passing a growing JSON array via `jq --argjson` exceeds the Linux kernel's ARG_MAX limit (~2-3 MB) once enough PR data accumulates. The daily run hit this at 252 PRs across 8 repos (exit code 126, "Argument list too long"). Switch both the PR and issues accumulation loops to the NDJSON pattern already used in the Behind-Base Detection section: emit one compact JSON line per item into a string variable, then slurp into an array once at the end with `jq -cs '.'`. No PR/issue data ever passes through a command-line argument. Regression test (8 repos × 35 PRs = 280 synthetic PRs): - Old pattern: Argument list too long at repo 7/8 - New pattern: 280 PRs accumulated successfully Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(org-status): address review comments — full ARG_MAX coverage + <<< style Address Gemini review on PR #258: - collect_classify_prs: replace --argjson page accumulation (all_nodes) with NDJSON pattern; protects against repos with many PR pages, not just large org totals. Also switch echo | jq to <<< throughout the function. - Merge activity: write ORG_MERGES/PERSONAL_MERGES to DATA_DIR/merges.json via printf (bash builtin, no exec, no ARG_MAX) so MERGE_DAILY and MERGE_BY_REPO_DAY read from a file descriptor instead of --argjson args. - All remaining echo "$x" | jq and printf | jq replaced with <<< herestrings as suggested (more idiomatic, avoids echo flag interpretation edge case). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* fix(org-status): avoid ARG_MAX crash when org has 200+ open PRs Passing a growing JSON array via `jq --argjson` exceeds the Linux kernel's ARG_MAX limit (~2-3 MB) once enough PR data accumulates. The daily run hit this at 252 PRs across 8 repos (exit code 126, "Argument list too long"). Switch both the PR and issues accumulation loops to the NDJSON pattern already used in the Behind-Base Detection section: emit one compact JSON line per item into a string variable, then slurp into an array once at the end with `jq -cs '.'`. No PR/issue data ever passes through a command-line argument. Regression test (8 repos × 35 PRs = 280 synthetic PRs): - Old pattern: Argument list too long at repo 7/8 - New pattern: 280 PRs accumulated successfully Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(org-status): address review comments — full ARG_MAX coverage + <<< style Address Gemini review on PR #258: - collect_classify_prs: replace --argjson page accumulation (all_nodes) with NDJSON pattern; protects against repos with many PR pages, not just large org totals. Also switch echo | jq to <<< throughout the function. - Merge activity: write ORG_MERGES/PERSONAL_MERGES to DATA_DIR/merges.json via printf (bash builtin, no exec, no ARG_MAX) so MERGE_DAILY and MERGE_BY_REPO_DAY read from a file descriptor instead of --argjson args. - All remaining echo "$x" | jq and printf | jq replaced with <<< herestrings as suggested (more idiomatic, avoids echo flag interpretation edge case). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* fix(org-status): avoid ARG_MAX crash when org has 200+ open PRs Passing a growing JSON array via `jq --argjson` exceeds the Linux kernel's ARG_MAX limit (~2-3 MB) once enough PR data accumulates. The daily run hit this at 252 PRs across 8 repos (exit code 126, "Argument list too long"). Switch both the PR and issues accumulation loops to the NDJSON pattern already used in the Behind-Base Detection section: emit one compact JSON line per item into a string variable, then slurp into an array once at the end with `jq -cs '.'`. No PR/issue data ever passes through a command-line argument. Regression test (8 repos × 35 PRs = 280 synthetic PRs): - Old pattern: Argument list too long at repo 7/8 - New pattern: 280 PRs accumulated successfully Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(org-status): address review comments — full ARG_MAX coverage + <<< style Address Gemini review on PR #258: - collect_classify_prs: replace --argjson page accumulation (all_nodes) with NDJSON pattern; protects against repos with many PR pages, not just large org totals. Also switch echo | jq to <<< throughout the function. - Merge activity: write ORG_MERGES/PERSONAL_MERGES to DATA_DIR/merges.json via printf (bash builtin, no exec, no ARG_MAX) so MERGE_DAILY and MERGE_BY_REPO_DAY read from a file descriptor instead of --argjson args. - All remaining echo "$x" | jq and printf | jq replaced with <<< herestrings as suggested (more idiomatic, avoids echo flag interpretation edge case). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* fix(org-status): avoid ARG_MAX crash when org has 200+ open PRs Passing a growing JSON array via `jq --argjson` exceeds the Linux kernel's ARG_MAX limit (~2-3 MB) once enough PR data accumulates. The daily run hit this at 252 PRs across 8 repos (exit code 126, "Argument list too long"). Switch both the PR and issues accumulation loops to the NDJSON pattern already used in the Behind-Base Detection section: emit one compact JSON line per item into a string variable, then slurp into an array once at the end with `jq -cs '.'`. No PR/issue data ever passes through a command-line argument. Regression test (8 repos × 35 PRs = 280 synthetic PRs): - Old pattern: Argument list too long at repo 7/8 - New pattern: 280 PRs accumulated successfully Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(org-status): address review comments — full ARG_MAX coverage + <<< style Address Gemini review on PR #258: - collect_classify_prs: replace --argjson page accumulation (all_nodes) with NDJSON pattern; protects against repos with many PR pages, not just large org totals. Also switch echo | jq to <<< throughout the function. - Merge activity: write ORG_MERGES/PERSONAL_MERGES to DATA_DIR/merges.json via printf (bash builtin, no exec, no ARG_MAX) so MERGE_DAILY and MERGE_BY_REPO_DAY read from a file descriptor instead of --argjson args. - All remaining echo "$x" | jq and printf | jq replaced with <<< herestrings as suggested (more idiomatic, avoids echo flag interpretation edge case). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
* fix(org-status): avoid ARG_MAX crash when org has 200+ open PRs Passing a growing JSON array via `jq --argjson` exceeds the Linux kernel's ARG_MAX limit (~2-3 MB) once enough PR data accumulates. The daily run hit this at 252 PRs across 8 repos (exit code 126, "Argument list too long"). Switch both the PR and issues accumulation loops to the NDJSON pattern already used in the Behind-Base Detection section: emit one compact JSON line per item into a string variable, then slurp into an array once at the end with `jq -cs '.'`. No PR/issue data ever passes through a command-line argument. Regression test (8 repos × 35 PRs = 280 synthetic PRs): - Old pattern: Argument list too long at repo 7/8 - New pattern: 280 PRs accumulated successfully Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(org-status): address review comments — full ARG_MAX coverage + <<< style Address Gemini review on PR #258: - collect_classify_prs: replace --argjson page accumulation (all_nodes) with NDJSON pattern; protects against repos with many PR pages, not just large org totals. Also switch echo | jq to <<< throughout the function. - Merge activity: write ORG_MERGES/PERSONAL_MERGES to DATA_DIR/merges.json via printf (bash builtin, no exec, no ARG_MAX) so MERGE_DAILY and MERGE_BY_REPO_DAY read from a file descriptor instead of --argjson args. - All remaining echo "$x" | jq and printf | jq replaced with <<< herestrings as suggested (more idiomatic, avoids echo flag interpretation edge case). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>



Summary
jq -n --argjson a "$ALL_PRS" --argjson b "$prs"passes the accumulated PR array as a shell argument. After 252 PRs across 8 repos the variable exceeded Linux'sARG_MAXlimit (~3 MB on this runner), causing exit 126 (E2BIG: Argument list too long) in run 25736549959.jq -cs '.'. No batch data ever passes through a command-line argument.Regression proof
Synthetic dataset: 8 repos × 35 PRs = 280 PRs (matching live scale).
Test plan
workflow_dispatch) or wait for next scheduled run — expect the "Generate org status report" step to succeed🤖 Generated with Claude Code