Skip to content

Fix mirror step failing after a successful copy#59

Merged
toddysm merged 1 commit into
mainfrom
fix/mirror-summary-exit-code
Jun 9, 2026
Merged

Fix mirror step failing after a successful copy#59
toddysm merged 1 commit into
mainfrom
fix/mirror-summary-exit-code

Conversation

@toddysm

@toddysm toddysm commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Problem

The scheduled mirror / quarantine/python run #27183374610 failed after the image copied successfully — the log shows Copied. New destination digest: sha256:c845af93… immediately followed by ##[error]Process completed with exit code 1.

Root cause

The job summary block in _mirror-image.yml ended with:

[ -n "${referrers_note}" ] && echo "${referrers_note}"

On the standard mirror path (no copy_referrers), referrers_note is empty, so [ -n "" ] returns a non-zero status. Because this was the final command in the step running under set -euo pipefail, that non-zero status became the step's exit code and failed the job — despite a successful copy.

It only surfaced now because the bug requires an actual copy to happen: when the source and destination digests matched, the step short-circuited earlier with exit 0. The python:3.14-slim upstream update changed the digest, triggering a real copy and exposing the latent bug.

Fix

Replace the [ ... ] && echo shorthand with an if, which returns 0 when referrers_note is empty:

if [ -n "${referrers_note}" ]; then echo "${referrers_note}"; fi

Validation

  • shellcheck -S warning passes on the main script step (the only remaining finding is the known SC2296 false positive on the ${{ }} login step).
  • No other [ ... ] && cmd trailing-command hazards remain in the file.
  • The referrer-aware path is unaffected (it sets referrers_note, so the echo runs either way).

The mirror summary block ended with:

    [ -n "${referrers_note}" ] && echo "${referrers_note}"

On the standard (non-referrer) mirror path referrers_note is empty, so the
test returns non-zero. As the final command in the step under `set -e`, that
non-zero status failed the job even though the image copied successfully
("Copied. New destination digest..."). It only surfaced when an actual copy
happened; when digests matched the step short-circuited with exit 0.

Replace the `[ ... ] && echo` shorthand with an `if`, which returns 0 when
referrers_note is empty.

Fixes the failure in mirror / quarantine/python (run 27183374610).
Copilot AI review requested due to automatic review settings June 9, 2026 04:17
@toddysm toddysm merged commit 90c1802 into main Jun 9, 2026
1 check passed
@toddysm toddysm deleted the fix/mirror-summary-exit-code branch June 9, 2026 04:17

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

Fixes a failure mode in the reusable image mirroring workflow where a successful copy could still end the job with exit code 1 due to the final summary-writing command returning non-zero under set -euo pipefail.

Changes:

  • Replace a trailing [ ... ] && echo ... summary line with an if block so an empty referrers_note doesn’t fail the step.
  • Add an in-script comment documenting why the if form is required under set -e.

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

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.

2 participants