Skip to content

PREQ-7525 Fail promote job when multi-repo promotion API call returns an error - #329

Merged
tomverin merged 2 commits into
masterfrom
jh/fail-promote-on-multi-repo-error
Jul 23, 2026
Merged

PREQ-7525 Fail promote job when multi-repo promotion API call returns an error#329
tomverin merged 2 commits into
masterfrom
jh/fail-promote-on-multi-repo-error

Conversation

@henryju

@henryju henryju commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary

  • We just hit a case on sonar-scanner-engine PR #525 where the Promote job (with multi-repo: true) reported success on GitHub, but the actual JFrog multiRepoPromote plugin call returned a 404 (The execution name 'multiRepoPromote' could not be found.). Because promote_multi() only printed the curl response without inspecting it, the failure was silently swallowed, the artifact was never promoted to sonarsource-private-dev, and the downstream deploy job failed later with a confusing "no artifact found" error.
  • This makes promote_multi() check the JSON response for an errors field and fail the step (with a clear ::error:: annotation) when the Artifactory plugin call itself fails, instead of only failing much later in an unrelated deploy job.

Test plan

  • ./run_shell_tests.sh (via mise exec -- shellspec spec/promote_spec.sh --shell bash) — 32 examples, 0 failures, including a new case simulating the exact 404 response seen in the wild
  • shellcheck promote/promote.sh — clean

🤖 Generated with Claude Code

The multiRepoPromote Artifactory plugin call in promote_multi() only
printed the JSON response without checking it for errors, so an error
response (e.g. HTTP 404 when the plugin execution isn't registered)
was silently ignored and the Promote job reported success even though
no artifact was actually promoted.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@henryju
henryju requested a review from a team as a code owner July 23, 2026 10:19
Copilot AI review requested due to automatic review settings July 23, 2026 10:19
@hashicorp-vault-sonar-prod hashicorp-vault-sonar-prod Bot changed the title Fail promote job when multi-repo promotion API call returns an error PREQ-7525 Fail promote job when multi-repo promotion API call returns an error Jul 23, 2026
@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Jul 23, 2026

Copy link
Copy Markdown

PREQ-7525

Comment thread promote/promote.sh
Comment thread promote/promote.sh Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ensures the multi-repo Artifactory promotion step fails fast (and annotates the workflow) when the multiRepoPromote plugin returns an error response, preventing silent “success” in GitHub Actions that later causes confusing downstream failures.

Changes:

  • Capture and print the jf rt curl response in promote_multi(), and fail the step when the JSON response contains an errors field.
  • Add ShellSpec coverage for the real-world 404 plugin error response case.
  • Extend the ShellSpec jq mock to support the new .errors checks.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
promote/promote.sh Adds JSON error detection/step failure logic for multi-repo promotion responses.
spec/promote_spec.sh Adds tests and mock behavior to validate failing on multi-repo promotion error responses.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread promote/promote.sh Outdated
…keep ::error single-line

- Fail loudly (instead of silently succeeding) when the multiRepoPromote
  plugin returns a non-JSON response, e.g. a gateway error page or empty
  body on a transient failure.
- Don't treat an empty `errors` array as a failure.
- Use `jq -c` and flatten the raw response with `tr` so the emitted
  ::error:: workflow command stays on a single line even when the
  Artifactory response is pretty-printed JSON spanning multiple lines.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@tomverin
tomverin enabled auto-merge (squash) July 23, 2026 11:49
@tomverin
tomverin merged commit 8831b23 into master Jul 23, 2026
19 checks passed
@tomverin
tomverin deleted the jh/fail-promote-on-multi-repo-error branch July 23, 2026 11:49
@gitar-bot

gitar-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 2 resolved / 2 findings

Adds error handling to the multi-repo promotion API call to fail the job when Artifactory returns an error, addressing the non-JSON/empty-errors edge cases and single-line annotation formatting.

✅ 2 resolved
Edge Case: Non-JSON / hard curl failures still slip through

📄 promote/promote.sh:137-142
jq -e '.errors' only detects failure when the response is valid JSON containing an errors field. If jf rt curl returns a non-JSON body (e.g. an HTML gateway error or empty output on a transient failure), jq exits non-zero, the if is false, and promote_multi returns success — reintroducing the silent-swallow bug for that failure mode. Note the plugin returned a JSON body here so this path is covered, but consider also validating that jf rt curl succeeded and the response parses as JSON (e.g. jq -e 'type=="object"') before concluding success.

Edge Case: An empty errors array would be treated as a failure

📄 promote/promote.sh:139
jq -e '.errors' returns exit 0 for any value that is not null/false, including an empty array []. If the multiRepoPromote plugin ever returns {"errors": []} on success, this would wrongly fail the promote step. If that is a possibility, guard against it with something like jq -e '.errors | length > 0' so only a non-empty error list triggers the failure.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants