Skip to content

Commit 554171b

Browse files
Fix: Use correct registry URL for fetching OCI image credentials (#45)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent f6cf90f commit 554171b

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

pkg/clip/oci_indexer.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,25 @@ func (ca *ClipArchiver) IndexOCIImage(ctx context.Context, opts IndexOCIImageOpt
109109
// Build remote options with authentication
110110
remoteOpts := []remote.Option{remote.WithContext(ctx)}
111111

112+
// IMPORTANT: Get credentials for the SOURCE registry (where we're fetching from),
113+
// not the storage reference (which is just stored in metadata)
114+
fetchRegistryURL := ref.Context().RegistryStr()
115+
fetchRepository := ref.Context().RepositoryStr()
116+
112117
// Try to get credentials from provider
113-
authConfig, err := credProvider.GetCredentials(ctx, registryURL, repository)
118+
authConfig, err := credProvider.GetCredentials(ctx, fetchRegistryURL, fetchRepository)
114119
if err != nil && err != common.ErrNoCredentials {
115120
log.Warn().
116121
Err(err).
117-
Str("registry", registryURL).
122+
Str("registry", fetchRegistryURL).
118123
Str("provider", credProvider.Name()).
119124
Msg("Failed to get credentials from provider, falling back to keychain")
120125
}
121126

122127
if authConfig != nil {
123128
// Use provided credentials
124129
log.Debug().
125-
Str("registry", registryURL).
130+
Str("registry", fetchRegistryURL).
126131
Str("provider", credProvider.Name()).
127132
Msg("Using credentials from provider")
128133
// Convert AuthConfig to proper authenticator (handles all auth types: username/password, tokens, etc.)
@@ -131,7 +136,7 @@ func (ca *ClipArchiver) IndexOCIImage(ctx context.Context, opts IndexOCIImageOpt
131136
} else {
132137
// Fall back to default keychain for anonymous or keychain-based auth
133138
log.Debug().
134-
Str("registry", registryURL).
139+
Str("registry", fetchRegistryURL).
135140
Msg("No credentials from provider, using default keychain")
136141
remoteOpts = append(remoteOpts, remote.WithAuthFromKeychain(authn.DefaultKeychain))
137142
}

0 commit comments

Comments
 (0)