Skip to content

client: surface last-response details after retries are exhausted#2796

Merged
bobcallaway merged 1 commit intosigstore:mainfrom
alliasgher:fix-retry-error-handler
Apr 22, 2026
Merged

client: surface last-response details after retries are exhausted#2796
bobcallaway merged 1 commit intosigstore:mainfrom
alliasgher:fix-retry-error-handler

Conversation

@alliasgher
Copy link
Copy Markdown
Contributor

Summary

When retryablehttp exhausts retries, its default failure message is just:

<METHOD> <URL> giving up after N attempt(s)

If the last failure was a transport error the detail survives via %w wrapping, but if the server returned a non-retryable error response (e.g. 5xx with a body explaining the problem), retryablehttp drains and discards the body — users see no root cause. That's the exact scenario reported in #2640.

This PR installs a custom retryablehttp.ErrorHandler on the Rekor client so the final error includes:

  • The wrapped transport error when one is present, or
  • The final HTTP status code and a bounded (512-byte) body snippet from the response.

Fixes #2640

Test plan

  • go test ./pkg/client/
  • gofmt clean
  • New TestRetryErrorHandlerSurfacesServerResponse: runs the client against a test server returning 500 + body "database unavailable"; asserts the final error contains both status 500 and the body text.

Signed-off-by: Ali alliasgher123@gmail.com

When retryablehttp exhausts retries, its default failure message is
just "<METHOD> <URL> giving up after N attempt(s)". If the final
failure was a transport error that detail survives via %w wrapping,
but if the server returned a non-retryable error response (e.g. 5xx
with a body explaining the failure) the response is drained and
discarded, so users see no root cause — the exact scenario sigstore#2640
describes.

Install a custom retryablehttp.ErrorHandler that includes:

* the wrapped error when a transport error is present
* the final status code and a bounded body snippet when the response
  is available

Adds TestRetryErrorHandlerSurfacesServerResponse asserting that a run
against a server returning 500 with body "database unavailable"
produces an error containing both "status 500" and the body text.

Fixes sigstore#2640

Signed-off-by: Ali <alliasgher123@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

❌ Patch coverage is 62.50000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 25.22%. Comparing base (488eb97) to head (ea377d9).
⚠️ Report is 670 commits behind head on main.

Files with missing lines Patch % Lines
pkg/client/rekor_client.go 62.50% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2796       +/-   ##
===========================================
- Coverage   66.46%   25.22%   -41.24%     
===========================================
  Files          92      191       +99     
  Lines        9258    25382    +16124     
===========================================
+ Hits         6153     6402      +249     
- Misses       2359    18151    +15792     
- Partials      746      829       +83     
Flag Coverage Δ
e2etests 46.22% <6.25%> (-1.34%) ⬇️
unittests 16.30% <62.50%> (-31.38%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bobcallaway bobcallaway merged commit 93da954 into sigstore:main Apr 22, 2026
16 checks passed
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.

Client: Print Last Error After Rekor Retires Fail

2 participants