pr-comment: pipe POST body via stdin to avoid curl ARG_MAX failure#119
Merged
Merged
Conversation
Same class of bug as #118 (jq ARG_MAX), one layer down. After #118 fixed the jq invocation, the next line on the failure path is response=$(curl ... -d "$payload") The full JSON payload (~4 MB for the customer spec that surfaced the jq case) goes through curl's argv via `-d`, exceeds the OS argument- length limit (ARG_MAX, typically 2 MB on Linux), and the script aborts with: /entrypoint.sh: line 124: curl: Argument list too long right after the (now-successful) jq step, with the same downstream symptoms: free `::notice::` URL printed, no PR comment posted, no review-token link generated. Customer saw "same problem" after bumping their pin to @main with #118 applied — the jq step now works but the next layer hits the same trap. Fix: pipe the payload to curl via stdin and use `--data-binary @-` to consume from stdin. printf is a shell builtin so the variable never goes through execve. Same shape as the jq fix. Extends the test workflow with `pr_comment_curl_handles_large_payload`, a companion to the existing `pr_comment_handles_large_payload`. The previous test exercises the jq path with an empty oasdiff_token, which short-circuits past the curl step. The new test exercises the curl step itself by providing a non-empty token and stubbing both oasdiff (multi-MB changelog source) and curl (records the body byte count from stdin and emits a fake 200 response). Asserts the curl stub was invoked with >4 MB of body — proves the payload made it through stdin without hitting ARG_MAX on argv. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Same class of bug as #118, one layer down. After #118 fixed the
jqinvocation, the next line on the failure path is:response=$(curl ... -d "$payload")The full JSON payload (~4 MB for the customer spec that surfaced the original jq case) goes through curl's argv via
-d, exceeds the OS argument-length limit, and the script aborts with:Downstream symptoms are identical to the original: free
::notice::URL printed before the failure, no PR comment posted, no review-token link generated.Fix
Pipe the payload to curl via stdin using
--data-binary @-.printfis a POSIX shell builtin so the variable never goes through execve.Regression test
A companion job
pr_comment_curl_handles_large_payloadjoins the existingpr_comment_handles_large_payload. The previous test exercises the jq path with an emptyoasdiff_token, which short-circuits past the curl step. This one provides a non-empty token and stubs bothoasdiff(multi-MB changelog source) andcurl(records body byte count from stdin, emits a fake 200 response). Asserts the curl stub received >4 MB of body — proves the payload made it through stdin without hitting ARG_MAX on argv.If someone reverts to
-d "$payload", the synthetic 4 MB payload trips ARG_MAX on the runner and the test fails with a specific pointer at the cause.Discovered by
Same customer thread as #118. After they bumped their pin to
@mainwith #118 applied, the jq step now succeeds but the very next line fails identically, one layer down. Worth a quick code-walk of the entire failure path for any other--arg "$bigvar"patterns that might also trip ARG_MAX (none found — these were the two).Test plan
bash -n pr-comment/entrypoint.shclean@mainand confirms the Pro PR comment finally appearsCo-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Generated with Claude Code