fix(ci): correctly extract rollback app/chart versions in promotion PRs#3463
Merged
Conversation
Auto-generated promotion PRs render the Rollback Reference as 'app=unknown, chart=unknown' (e.g. #3447, #3461). Root cause: the version extraction used 'python3 -c "..."' double-quoted inside $(...), so bash collapsed the [\"\''] quote class to ["\''] within the program text and Python raised 'SyntaxError: closing parenthesis ]' — swallowed by 2>&1 and turned into 'unknown'. Both fields failed identically, hence both unknown. Rewrite extraction via a single-quoted heredoc (no bash substitution on the regex), passing the YAML through an env var. Verified against the prod helmrelease live when #3447 was generated: now yields the real app=v6.101.14-prod.3, chart=0.85.12-prod.1. Hardening folded in: - Fetch refs with explicit forced refspecs so origin/<target> is reliably the true remote tip for both changelog and rollback lookup. - Randomize the GITHUB_OUTPUT heredoc delimiter for ai_summary so a model summary containing a bare 'EOF' line can't inject extra output keys. - Resolve the 'already exists' PR URL by SOURCE->TARGET via 'gh pr list' (jq '// empty') instead of a bare 'gh pr view' that returned the wrong PR. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📊 Code Quality Score: 3/100
Was this score accurate? 👍 Yes · 👎 No Scored by GitVelocity · How are scores calculated? |
📊 Code Quality Score: 3/100
Was this score accurate? 👍 Yes · 👎 No Scored by GitVelocity · How are scores calculated? |
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
Auto-generated promotion PRs render the Rollback Reference as
app=unknown, chart=unknown— e.g. #3447 and #3461 (preprod → prod, 2026-06-30). The "Current on prod" line should show the versions you'd roll back to.Root cause
The version extraction used
python3 -c "..."double-quoted inside$(...), so bash collapsed the[\"\'']quote class to["\'']within the program text. Python then raisedSyntaxError: closing parenthesis ']' does not match— which2>&1swallowed and|| ="unknown"turned intounknown. Both app and chart failed identically, hence both showedunknown. Reproduced against the exact prod helmrelease that was live when #3447 was generated.Fix
'PYEOF') so bash performs no substitution on the regex, passing the YAML through an env var instead of the command line. Verified: now yieldsapp=v6.101.14-prod.3, chart=0.85.12-prod.1for the Promote to prod — 2026-06-28 07:33 UTC #3447 snapshot, andapp=v6.103.0-prod.1, chart=0.86.0-prod.1for current prod.Hardening folded in (same file)
refs/heads/<b>:refs/remotes/origin/<b>) soorigin/<target>is reliably the true remote tip for both the changelog and the rollback lookup.GITHUB_OUTPUTheredoc delimiter forai_summaryso a model-generated summary containing a bareEOFline can't inject extra output keys (Actions output injection).SOURCE→TARGETpair viagh pr list --base --head --jq '.[0].url // empty'instead of a baregh pr viewthat returned the runner's current-branch PR.Scope
build/ci/generate-promotion-pr.shonly — a focused fix so it can merge ahead of the larger reverse-promotion feature (#3382). The script content is identical to the copy on #3382, so the two converge cleanly (no conflict) whichever merges first.Testing
bash -nclean.🤖 Generated with Claude Code