From c1cbe3e008e12691fb99a06aed50b8b1bf5cc557 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 28 Sep 2026 13:13:06 -0500 Subject: [PATCH] PYTHON-6125 Stop swallowing spec resync PR creation errors --- .evergreen/scripts/create-spec-pr.sh | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.evergreen/scripts/create-spec-pr.sh b/.evergreen/scripts/create-spec-pr.sh index 1de1a7cae1..0867ae5487 100755 --- a/.evergreen/scripts/create-spec-pr.sh +++ b/.evergreen/scripts/create-spec-pr.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -eu tools="$(realpath -s "../drivers-tools")" pushd $tools/.evergreen/github_app || exit @@ -37,14 +38,32 @@ git commit -am "resyncing specs $(date '+%m-%d-%Y')" echo "Creating the git checkout... done." git push origin $branch + +# Build the payload as a file so the body content is always properly +# JSON-escaped, rather than interpolated into the command line as text. +payload_file=$(mktemp) +trap 'rm -f "$payload_file"' EXIT +jq -n \ + --arg title "[Spec Resync] $(date '+%m-%d-%Y')" \ + --arg head "${branch}" \ + --rawfile body "$1" \ + '{title: $title, body: $body, head: $head, base: "main"}' > "$payload_file" + resp=$(curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer $token" \ -H "X-GitHub-Api-Version: 2022-11-28" \ - -d "{\"title\":\"[Spec Resync] $(date '+%m-%d-%Y')\",\"body\":\"$(cat "$1")\",\"head\":\"${branch}\",\"base\":\"main\"}" \ + -d "@${payload_file}" \ --url https://api.github.com/repos/$owner/$repo/pulls) -echo $resp | jq '.html_url' + +pr_url=$(echo "$resp" | jq -r '.html_url // empty') +if [ -z "$pr_url" ]; then + echo "Failed to create PR! API response:" + echo "$resp" | jq . + exit 1 +fi +echo "$pr_url" echo "Creating the PR... done." rm -rf $tools