fix(promote): git-tag existence check misread 422 as an existing tag#28
fix(promote): git-tag existence check misread 422 as an existing tag#28bdimitrov-netzine wants to merge 1 commit into
Conversation
…g tag) The 'Tag promoted commit' step used `gh api repos/$REPO/commits/$TAG` to resolve an existing tag to its commit. For a tag that does not exist, that endpoint returns HTTP 422 with a JSON error body; gh api prints the body to stdout and skips --jq, so `2>/dev/null || true` captured the raw JSON into CUR. A non-empty, non-matching CUR then tripped the never-move guard and the job failed with 'Refusing to move the tag' — even though the tag was absent. Switch the existence check to the refs API (git/ref/tags/$TAG), which cleanly 404s when the tag is missing, and only resolve the commit when it exists. Preserves the create-only / never-move / idempotent semantics. Observed on run 29075877856 (testnet-v1.2.2 promotion); the tag was created manually out-of-band so this only fixes the workflow going forward.
|
Claude finished @bdimitrov-netzine's task in 1m 0s —— View job PR Review
Verdict: LGTM — the fix is correct and well-reasoned. Root cause diagnosisThe PR description is accurate. The fix- # Idempotent + never-move: resolve any existing tag to its commit.
- CUR=$(gh api "repos/$REPO/commits/$TAG" --jq '.sha' 2>/dev/null || true)
- if [ -n "$CUR" ]; then
+ # Idempotent + never-move
+ if gh api "repos/$REPO/git/ref/tags/$TAG" >/dev/null 2>&1; then
+ CUR=$(gh api "repos/$REPO/commits/$TAG" --jq '.sha')
if [ "$CUR" = "$COMMIT" ]; thenWhy this works:
Design correctness for annotated tags: No issues found
|
Security Scan - CodeSeverity: HIGH, CRITICAL No vulnerabilities found View scan results |
Fix
Use the refs API (
git/ref/tags/$TAG) for a clean existence check (real 404 when missing), and only resolve the commit when the tag actually exists. Create-only / never-move / idempotent semantics are unchanged.