Fix inverted error check in NewRegistryClient#585
Open
jeffwidman wants to merge 1 commit intomainfrom
Open
Conversation
getRegistryAuthHeader() returns (user, pass, nil) on success and
("", "", error) on failure. The error check was inverted: the
err != nil branch set auth with empty credentials, while the
err == nil branch discarded valid credentials.
This caused all registry freshness queries (DigestExists,
GetLatestDigest) to go out unauthenticated, which could hit
stale CDN caches and incorrectly conclude images are up to date.
Fixes #583
jeffwidman
commented
Mar 4, 2026
Member
Author
jeffwidman
left a comment
There was a problem hiding this comment.
I realize there are no tests for this... there are actually no tests for any of this registry_client file...
I think it'd be great to add them, but I threw this PR up as a drive-by PR while focused on something completely different that happened to touch this, so adding a whole test suite is far out of scope for this change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getRegistryAuthHeader()returns(user, pass, nil)on success and("", "", error)on failure. The error check inNewRegistryClient()was inverted:err != nil(failure) → set auth with empty credentials (useless)err == nil(success) → discarded valid credentialsThis caused all registry freshness queries (
DigestExists,GetLatestDigest) to go out unauthenticated, even when valid credentials were available. Unauthenticated requests to GHCR may hit a stale CDN cache layer, causing the freshness check inpullImage()to incorrectly conclude images are already up to date.Fix
Changed
err != niltoerr == nilso credentials are used when available and omitted when not.Fixes #583