fix: report a clear error when chart-testing blob verification fails - #210
Conversation
|
Kind ping 🙂 — this has been green and awaiting review for about 5 weeks now. Happy to rebase or address any feedback whenever a maintainer has a chance to take a look. Thanks for maintaining this project! |
|
Open since June with no review. Is a clearer error on chart-testing blob verification failure something you would take? Happy to close if not, otherwise this is green and ready. |
|
@somaz94 can you rebase? |
Signed-off-by: somaz <genius5711@gmail.com>
3e77678 to
34e97ae
Compare
|
Rebased onto the latest main no conflicts, the diff is unchanged. |
cpanato
left a comment
There was a problem hiding this comment.
🤖 (summary)
Reviewed with two models (Opus 4.8 + Fable 5) plus manual verification, against 34e97ae. LGTM.
Confirmed both claims in the description: log_error is defined nowhere in the repo, and under set -o errexit the retVal=$? branch was unreachable, so the intended message never fired. Verified with a fake cosign on PATH that the new if ! cosign ... still aborts before tar -xzf for exit codes 1/2/127/130/255 on bash 3.2 and 5.3 — the verification gate is intact, and the success-path output is byte-identical to before. shellcheck/bash -n/zsh -n clean.
Thanks for the rebase, and sorry for the long wait on this one. The e2e workflow had never actually run on the previous head (only DCO), so it was never as green as it looked — it's running now.
One note for the record, not a change request for this PR: the failure exit code narrows from cosign's status to a constant 1. Nothing observes it (action.yml only distinguishes zero from non-zero), so it's fine as-is.
Separately, the review turned up a pre-existing issue that is not from this PR and is present on main today: mkdir -p "${cache_dir}" at ct.sh:91 runs before download/verify, so a cache dir left behind by a failed run makes every subsequent run skip cosign entirely and put an unverified binary on PATH. Reproducible on main and on this branch identically. Bounded on GitHub-hosted runners (fresh tool cache per job), but real on self-hosted/reused runners. Worth a separate issue — this PR actually makes that failure mode easier to notice, which is another reason to take it.
Under
set -o errexit, theretVal=$?check aftercosign verify-blobwasunreachable: a non-zero
cosign verify-blobaborts the script immediately, sothe intended "Unable to validate chart-testing version" message never fired. The
error branch also called
log_error, which is not defined anywhere inct.sh(it would fail with
command not foundif it were ever reached).This rewrites the check as
if ! cosign verify-blob ...; then, which suspendserrexit for the tested command so the failure branch is actually reached, and
replaces the undefined
log_errorwithecho "ERROR: ..." >&2, matching theexisting error style used in
parse_command_line. Behavior on success isunchanged; on verification failure the script now prints the intended clear
error and exits 1.
Validation:
bash -n ct.shandzsh -n ct.shparse cleanshellcheck ct.shcleanif ! cmdreaches the failure branch underset -o errexitNote: open PR #205 wraps this same block in a
verify_blobtoggle but copies thebroken
retVal/log_errorpattern verbatim, so this fix is complementaryregardless of merge order.