fix(git-commit, git-copy): build API payloads with jq to escape JSON properly - #199
Open
VojtechVitek wants to merge 2 commits into
Open
fix(git-commit, git-copy): build API payloads with jq to escape JSON properly#199VojtechVitek wants to merge 2 commits into
VojtechVitek wants to merge 2 commits into
Conversation
The pull request payload was hand-built with string interpolation and only escaped newlines. Any double quote, backslash, or carriage return in pr_title/pr_description produced invalid JSON and the PR creation silently failed. GitHub release notes use CRLF line endings, so passing them as pr_description always broke. - Build the PR creation payload with jq -n --arg (escapes everything) - Build the labels payload with jq instead of manual concatenation (also drops the leaked IFS=',' assignment) - Fix stray '}' in the update_labels curl credentials Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Same fixes as git-commit: the PR and labels payloads were hand-built with string interpolation and broke on quotes, backslashes, or CRLF in pr_title/pr_description/pr_labels. Co-Authored-By: Claude Fable 5 <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.
Problem
Both
git-commitandgit-copybuild the pull-request creation payload by string interpolation and only escape newlines:Any double quote, backslash, or carriage return in
pr_title/pr_descriptionproduces invalid JSON, the API returns 400/422, and PR creation fails. GitHub release notes use CRLF line endings, so passing a release body aspr_descriptionalways breaks (reproduced with the realwebrpc/gen-golang v0.32.5notes:jq: parse error: control characters from U+0000 through U+001F must be escaped).Fix (applied identically to both actions)
jq -n --arg— correct escaping for all inputs, including the title.update_labelspayload withjqinstead of manual string concatenation. This also removes theIFS=','assignment that leaked out of the function.}in theupdate_labelscurl credentials:-u "$INPUT_USER_NAME}:$API_TOKEN_GITHUB".Also drops the
${var//...}bash-ism from#!/bin/shscripts.Testing
shellcheck -s shandsh -npass on both scripts (remaining warnings are pre-existing)."quotes",back\slash, CRLF): output is valid JSON and decodes byte-identical.Motivation: webrpc/webrpc wants to include generator release notes in automated bump PR descriptions, which is impossible with the current escaping.
🤖 Generated with Claude Code