Skip to content

Conversation

@majewsky
Copy link
Contributor

  • Returning *keppel.RegistryV2Error from AuthChallenge.GetToken() does not have any benefit, but causes a
    problem because the calling function can now return the non-nil empty error error((*keppel.RegistryV2Error)(nil)).
  • The API endpoint for monolithic blob uploads requires a slash at the end of the path. This trailing slash is required by the API specification, see end-4b in https://github.com/opencontainers/distribution-spec/blob/v1.1.1/spec.md#endpoints.

The more structured error type is not used at the callsite, but causes a
problem because the calling function can now return the non-nil empty
error `error((*keppel.RegistryV2Error)(nil))`.
The API endpoint for monolithic blob uploads requires a slash at the end
of the path. This trailing slash is required by the API specification,
see `end-4b` in [1].

[1] https://github.com/opencontainers/distribution-spec/blob/v1.1.1/spec.md#endpoints
@majewsky majewsky requested a review from a team as a code owner January 15, 2026 13:13
Query: url.Values{"digest": []string{d.String()}},
Headers: http.Header{
"Content-Type": {"application/octet-stream"},
"Content-Length": {strconv.FormatUint(uint64(len(contents)), 10)},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This header must now be added manually because the testcase does not go through a real HTTP server (where it would normally be added automatically).

Copy link
Member

Choose a reason for hiding this comment

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

That should probably be a comment

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes regressions in the package client and adds comprehensive test coverage. The main issues addressed are: (1) an error handling bug where returning *keppel.RegistryV2Error could result in a non-nil empty error, and (2) ensuring the monolithic blob upload endpoint preserves the required trailing slash per the OCI distribution specification.

Changes:

  • Fixed error handling in authentication to use error instead of *keppel.RegistryV2Error to prevent nil pointer issues
  • Added trailing slash preservation logic for API endpoints that require it
  • Added Content-Length header to monolithic blob uploads for better HTTP compliance
  • Added comprehensive test coverage for RepoClient upload and download operations

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/client/auth_challenge.go Changed GetToken return type from *keppel.RegistryV2Error to error to fix nil error handling bug
internal/client/repo_client.go Added trailing slash preservation and updated error handling to use error type consistently
internal/client/upload.go Added Content-Length header to monolithic blob upload requests
internal/test/content.go Added documentation for GenerateImageWithCustomConfig function
internal/client/repo_client_test.go New comprehensive test file covering RepoClient upload and download operations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

Merging this branch will increase overall coverage

Impacted Packages Coverage Δ 🤖
github.com/sapcc/keppel/internal/client 51.47% (+6.81%) 👍
github.com/sapcc/keppel/internal/test 87.10% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/sapcc/keppel/internal/client/auth_challenge.go 67.31% (ø) 572 (+312) 385 (+210) 187 (+102)
github.com/sapcc/keppel/internal/client/repo_client.go 90.24% (+4.20%) 451 (+236) 407 (+222) 44 (+14) 👍
github.com/sapcc/keppel/internal/client/upload.go 92.31% (+92.31%) 143 (+78) 132 (+132) 11 (-54) 🌟
github.com/sapcc/keppel/internal/test/content.go 85.14% (ø) 444 (+74) 378 (+63) 66 (+11)

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/sapcc/keppel/internal/client/repo_client_test.go

@majewsky majewsky merged commit 51919b0 into master Jan 16, 2026
6 checks passed
@majewsky majewsky deleted the repoclient-test-coverage branch January 16, 2026 15:07
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.

3 participants