Skip to content

fix: explicitly handle exhausted Trivy retries - #2339

Open
Yashh56 wants to merge 1 commit into
shipwright-io:mainfrom
Yashh56:fix-trivy-retry-exhaustion
Open

fix: explicitly handle exhausted Trivy retries#2339
Yashh56 wants to merge 1 commit into
shipwright-io:mainfrom
Yashh56:fix-trivy-retry-exhaustion

Conversation

@Yashh56

@Yashh56 Yashh56 commented Sep 7, 2026

Copy link
Copy Markdown

Changes

This PR fixes a bug in the image vulnerability scanning retry logic.

Previously, if all 10 retry attempts to download the Trivy vulnerability database failed, the loop would exit and incorrectly fall through to json.Unmarshal. Because the output contained the plain text connection error instead of valid JSON, this would cause a confusing JSON parsing panic (invalid character...) that masked the real execution error.

This PR:

  1. Adds an explicit check after the loop to return the underlying Trivy execution error if all retries are exhausted.
  2. Cleans up a redundant i < 10 check inside the for i := 0; i < 10; i++ loop.

Related Issue

Fixes #2329

Type of PR

/kind bug

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Kind label has been set
  • Release notes block has been filled in, or marked NONE

Release Notes

Fixed an issue where vulnerability scanning failures caused by Trivy database download timeouts would result in a confusing JSON parsing error instead of correctly reporting the underlying connection issue.

@openshift-ci openshift-ci Bot added the release-note Label for when a PR has specified a release note label Sep 7, 2026
@pull-request-size pull-request-size Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 7, 2026
@openshift-ci openshift-ci Bot added the kind/bug Categorizes issue or PR as related to a bug. label Sep 7, 2026
@openshift-ci
openshift-ci Bot requested review from IrvingMg and kaizakin September 7, 2026 15:02
@openshift-ci

openshift-ci Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign irvingmg for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

This commit fixes a bug where exhausting all 10 Trivy retries would result in a confusing JSON parse error instead of the underlying execution error. It also cleans up a redundant condition inside the retry loop.

Signed-off-by: Yash <yashsaini18166@gmail.com>
@Yashh56
Yashh56 force-pushed the fix-trivy-retry-exhaustion branch from c51bc23 to e891e8c Compare September 7, 2026 15:06

@kaizakin kaizakin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Label for when a PR has specified a release note size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Vulnerability scan retry loop can hide the actual Trivy error

3 participants