GoogleContainerTools/skaffold · error
failed to clone repo %s: trouble building repo URI with toke
Error message
failed to clone repo %s: trouble building repo URI with token: %w
What it means
After obtaining the repo URI and read token, GetRepoInfo combines them into an authenticated clone URI via buildRepoURIWithToken. If the URI is malformed for token embedding (e.g. unsupported scheme like ssh: or an unexpected format), this error is returned.
Source
Thrown at pkg/skaffold/gcbreposv2/repo_resolver.go:65
cbClient, err := RepositoryManagerClient(ctx)
if err != nil {
return Repo{}, fmt.Errorf("failed to create repository manager client: %w", err)
}
defer cbClient.Close()
repoURI, err := getRepoURI(ctx, cbClient, cbRepoRef)
if err != nil {
return Repo{}, fmt.Errorf("failed to get remote URI for repository %v: %w", gcpRepoName, err)
}
readAccessToken, err := getRepoReadAccessToken(ctx, cbClient, cbRepoRef)
if err != nil {
return Repo{}, fmt.Errorf("failed to get repository read access token for repo %v: %w", gcpRepoName, err)
}
repoCloneURI, err := buildRepoURIWithToken(repoURI, readAccessToken)
if err != nil {
return Repo{}, fmt.Errorf("failed to clone repo %s: trouble building repo URI with token: %w", repoURI, err)
}
return Repo{
URI: repoURI,
CloneURI: repoCloneURI,
}, nil
}
func repositoryManagerClient(ctx context.Context) (cloudBuildRepoClient, error) {
return cloudbuild.NewRepositoryManagerClient(ctx)
}
func getRepoURI(ctx context.Context, cbClient cloudBuildRepoClient, cbRepoRef string) (string, error) {
req := &cloudbuildpb.GetRepositoryRequest{
Name: cbRepoRef,
}
repoInfo, err := cbClient.GetRepository(ctx, req)
if err != nil {View on GitHub (pinned to a1189de023)
Solutions
- Ensure the connected repository's remote is an HTTPS URI (reconfigure the connection if it points to an SSH remote).
- Log/inspect buildRepoURIWithToken's parse error in the wrapped cause to see the offending URI format.
- Update Skaffold if the Artifact Registry host format changed (newer versions handle new hosts).
- As a workaround, clone using the gcloud credential helper rather than a token-embedded URI.
Example fix
// before (ssh remote on connection) remote: git@github.com:org/repo.git // after (https remote) remote: https://github.com/org/repo.git
Defensive patterns
Strategy: validation
Validate before calling
// Pre-check the remote URI scheme the connection uses
if !strings.HasPrefix(repoURI, "https://") {
return fmt.Errorf("repo remote %q is not HTTPS; token embedding unsupported", repoURI)
} Try / catch
repo, err := gcbreposv2.GetRepoInfo(ctx, proj, region, conn, name)
if err != nil && strings.Contains(err.Error(), "trouble building repo URI with token") {
return fmt.Errorf("connection remote must be HTTPS for token auth: %w", err)
} Prevention
- Configure the connected repository with an HTTPS remote, never SSH.
- Check for Skaffold/gcloud SDK updates if the Artifact Registry host format changed.
- Log the offending URI (in the wrapped cause) when diagnosing.
When it happens
Trigger: Calling GetRepoInfo when the remote URI returned by Cloud Build is not an HTTPS URI that can accept a token in the userinfo portion (e.g. an ssh:// URI or a URI without the expected pkg.dev host format).
Common situations: A repository whose connected remote uses SSH instead of HTTPS; a misconfigured connection returning a legacy or custom host; regional hosts with unexpected formats after Artifact Registry host changes.
Related errors
- failed to create repository manager client: %w
- failed to get remote URI for repository %v: %w
- failed to get repository read access token for repo %v: %w
- CONFIG_REMOTE_REPO_CACHE_NOT_FOUND_ERR
- INIT_CLOUD_RUN_LOCATION_ERROR
AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05).
Data as JSON: /api/errors/22ea5d5bbb94b0b2.
Report an issue: GitHub.