Skip to content

fix: preserve response body in retryError #2126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ryanbrainard
Copy link

@ryanbrainard ryanbrainard commented Aug 15, 2025

This is a fix for #2125. The retryError function was consuming the HTTP response body without restoring it for subsequent readers. This caused structured registry error messages to be lost during retries, falling back to generic HTTP status messages instead. (See #2125 for a reproducer.)

This change buffers the response body and creates a new readable stream so that both retryError and subsequent error handling can access the response content.

Before:

  • Without retry: MANIFEST_UNKNOWN: manifest unknown; unknown tag=v1.0.0
  • With retry: unexpected status code 404 Not Found

After:

  • Both cases: MANIFEST_UNKNOWN: manifest unknown; unknown tag=v1.0.0

Note, remote.CheckError() appears to also have the same issue, but I did not fix that since that appears to be called as a terminal operation where the caller doesn't need to read the body again after getting an error.

Fixes #2125

The retryError function was consuming the HTTP response body without
restoring it for subsequent readers. This caused structured registry
error messages to be lost during retries, falling back to generic
HTTP status messages instead.

This change buffers the response body and creates a new readable stream
so that both retryError and subsequent error handling can access the
response content.

Before:
- Without retry: MANIFEST_UNKNOWN: manifest unknown; unknown tag=v1.0.0
- With retry: unexpected status code 404 Not Found

After:
- Both cases: MANIFEST_UNKNOWN: manifest unknown; unknown tag=v1.0.0

Fixes google#2125
@ryanbrainard ryanbrainard changed the title fix: preserve response body in retryError for structured error messages fix: preserve response body in retryError Aug 15, 2025
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.

ggcr: retryError consumes HTTP response body
1 participant