Skip to content

Fix inverted error check in NewRegistryClient#585

Open
jeffwidman wants to merge 1 commit intomainfrom
fix-inverted-registry-auth
Open

Fix inverted error check in NewRegistryClient#585
jeffwidman wants to merge 1 commit intomainfrom
fix-inverted-registry-auth

Conversation

@jeffwidman
Copy link
Member

Summary

getRegistryAuthHeader() returns (user, pass, nil) on success and ("", "", error) on failure. The error check in NewRegistryClient() was inverted:

  • err != nil (failure) → set auth with empty credentials (useless)
  • err == nil (success) → discarded valid credentials

This 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 in pullImage() to incorrectly conclude images are already up to date.

Fix

Changed err != nil to err == nil so credentials are used when available and omitted when not.

Fixes #583

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 jeffwidman requested review from a team as code owners March 4, 2026 00:23
Copy link
Member Author

@jeffwidman jeffwidman left a comment

Choose a reason for hiding this comment

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

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.

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.

Inverted error check in NewRegistryClient discards auth credentials

1 participant