{"record":{"id":"22ea5d5bbb94b0b2","repo":"GoogleContainerTools/skaffold","slug":"failed-to-clone-repo-s-trouble-building-repo-uri","errorCode":null,"errorMessage":"failed to clone repo %s: trouble building repo URI with token: %w","messagePattern":"failed to clone repo (.+?): trouble building repo URI with token: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/gcbreposv2/repo_resolver.go","lineNumber":65,"sourceCode":"\tcbClient, err := RepositoryManagerClient(ctx)\n\tif err != nil {\n\t\treturn Repo{}, fmt.Errorf(\"failed to create repository manager client: %w\", err)\n\t}\n\tdefer cbClient.Close()\n\n\trepoURI, err := getRepoURI(ctx, cbClient, cbRepoRef)\n\tif err != nil {\n\t\treturn Repo{}, fmt.Errorf(\"failed to get remote URI for repository %v: %w\", gcpRepoName, err)\n\t}\n\n\treadAccessToken, err := getRepoReadAccessToken(ctx, cbClient, cbRepoRef)\n\tif err != nil {\n\t\treturn Repo{}, fmt.Errorf(\"failed to get repository read access token for repo %v: %w\", gcpRepoName, err)\n\t}\n\n\trepoCloneURI, err := buildRepoURIWithToken(repoURI, readAccessToken)\n\tif err != nil {\n\t\treturn Repo{}, fmt.Errorf(\"failed to clone repo %s: trouble building repo URI with token: %w\", repoURI, err)\n\t}\n\n\treturn Repo{\n\t\tURI:      repoURI,\n\t\tCloneURI: repoCloneURI,\n\t}, nil\n}\n\nfunc repositoryManagerClient(ctx context.Context) (cloudBuildRepoClient, error) {\n\treturn cloudbuild.NewRepositoryManagerClient(ctx)\n}\n\nfunc getRepoURI(ctx context.Context, cbClient cloudBuildRepoClient, cbRepoRef string) (string, error) {\n\treq := &cloudbuildpb.GetRepositoryRequest{\n\t\tName: cbRepoRef,\n\t}\n\trepoInfo, err := cbClient.GetRepository(ctx, req)\n\tif err != nil {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/gcbreposv2/repo_resolver.go#L47-L83","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before (ssh remote on connection)\nremote: git@github.com:org/repo.git\n// after (https remote)\nremote: https://github.com/org/repo.git","handlingStrategy":"validation","validationCode":"// Pre-check the remote URI scheme the connection uses\nif !strings.HasPrefix(repoURI, \"https://\") {\n    return fmt.Errorf(\"repo remote %q is not HTTPS; token embedding unsupported\", repoURI)\n}","typeGuard":null,"tryCatchPattern":"repo, err := gcbreposv2.GetRepoInfo(ctx, proj, region, conn, name)\nif err != nil && strings.Contains(err.Error(), \"trouble building repo URI with token\") {\n    return fmt.Errorf(\"connection remote must be HTTPS for token auth: %w\", err)\n}","preventionTips":["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."],"tags":["gcp","cloud-build","uri","git"],"backgroundTag":"malformed-url","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}