Skip to content

pkg/registry: return 202 Accepted for PATCH chunk uploads#2265

Merged
Subserial merged 3 commits into
google:mainfrom
alliasgher:fix-registry-patch-returns-202
Apr 16, 2026
Merged

pkg/registry: return 202 Accepted for PATCH chunk uploads#2265
Subserial merged 3 commits into
google:mainfrom
alliasgher:fix-registry-patch-returns-202

Conversation

@alliasgher

Copy link
Copy Markdown
Contributor

Fixes #2198. The OCI Distribution spec requires 202 Accepted for chunk upload PATCH responses; the registry was returning 204 No Content. Updated both PATCH paths in blobs.go and the corresponding test expectations.

retryError consumed resp.Body with io.ReadAll but discarded the bytes,
leaving the body closed. When the retry loop exhausted its attempts and
called CheckError, that function tried to read the same body and found
nothing, producing a generic "unexpected status code" error instead of
the structured registry error (e.g. MANIFEST_UNKNOWN).

After reading the body, restore it with io.NopCloser(bytes.NewReader(b))
so subsequent callers see the same bytes.

Fixes google#2125

Signed-off-by: alliasgher <alliasgher123@gmail.com>
The OCI Distribution spec (§10.5) and Docker Registry API require
HTTP 202 Accepted for successful chunk upload PATCH responses. The
registry was returning 204 No Content, which caused clients that
strictly validate the response code to fail or behave unexpectedly.

Update the two PATCH response paths in blobs.go and the corresponding
test expectations.

Fixes google#2198

Signed-off-by: alliasgher <alliasgher123@gmail.com>
@codecov-commenter

codecov-commenter commented Apr 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.93%. Comparing base (8b3c303) to head (7d8e7b8).
⚠️ Report is 92 commits behind head on main.

❗ There is a different number of reports uploaded between BASE (8b3c303) and HEAD (7d8e7b8). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (8b3c303) HEAD (7d8e7b8)
2 1
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2265       +/-   ##
===========================================
- Coverage   71.67%   52.93%   -18.75%     
===========================================
  Files         123      165       +42     
  Lines        9935    11208     +1273     
===========================================
- Hits         7121     5933     -1188     
- Misses       2115     4561     +2446     
- Partials      699      714       +15     

☔ 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.

Signed-off-by: alliasgher <alliasgher123@gmail.com>
@Subserial Subserial merged commit f80cb9a into google:main Apr 16, 2026
17 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.

ggcr: pkg/registry chunk upload endpoint returns HTTP 204 instead of HTTP 202

3 participants