{"record":{"id":"fee07d3a054e0dab","repo":"GoogleContainerTools/skaffold","slug":"failed-to-create-repository-manager-client-w","errorCode":null,"errorMessage":"failed to create repository manager client: %w","messagePattern":"failed to create repository manager client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/gcbreposv2/repo_resolver.go","lineNumber":49,"sourceCode":"\tFetchReadToken(ctx context.Context, req *cloudbuildpb.FetchReadTokenRequest, opts ...gax.CallOption) (*cloudbuildpb.FetchReadTokenResponse, error)\n\tClose() error\n}\n\ntype Repo struct {\n\t// Original repo URI.\n\tURI string\n\n\t// URI with oauth2 format.\n\tCloneURI string\n}\n\nvar RepositoryManagerClient = repositoryManagerClient\n\nfunc GetRepoInfo(ctx context.Context, gcpProject, gcpRegion, gcpConnectionName, gcpRepoName string) (Repo, error) {\n\tcbRepoRef := fmt.Sprintf(\"projects/%v/locations/%v/connections/%v/repositories/%v\", gcpProject, gcpRegion, gcpConnectionName, gcpRepoName)\n\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","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/gcbreposv2/repo_resolver.go#L31-L67","documentation":"GetRepoInfo resolves a Cloud Build (Artifact Registry) repository reference to its remote URI and access token. It first constructs a Repository Manager client via the RepositoryManagerClient function; if that client cannot be created (usually an auth or endpoint failure), it wraps the error with this message.","triggerScenarios":"Calling GetRepoInfo when the repository manager client factory fails: missing/invalid Application Default Credentials, gcloud not authenticated, network failure reaching the Repository Manager API, or a bad context (canceled deadline).","commonSituations":"Running Skaffold in CI without a service account key or ADC configured; no network access to googleapis.com; the gcbreposv2 feature used on a machine with no gcloud login; project/region values pointing at an endpoint the credentials cannot access.","solutions":["Run `gcloud auth application-default login` or set GOOGLE_APPLICATION_CREDENTIALS to a valid service-account key.","Verify network access to the Repository Manager API (repositorymanager.googleapis.com) from the environment.","Check the wrapped cause (context deadline / credential / transport error) and fix it specifically.","Retry if the failure was a transient network error or expired metadata-server token."],"exampleFix":"// before (CI with no creds)\n$ skaffold ... # fails: failed to create repository manager client\n// after\n$ gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS","handlingStrategy":"try-catch","validationCode":"creds, err := google.FindDefaultCredentials(ctx, \"https://www.googleapis.com/auth/cloud-platform\")\nif err != nil {\n    return fmt.Errorf(\"no GCP credentials available for repository manager: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"repo, err := gcbreposv2.GetRepoInfo(ctx, proj, region, conn, name)\nif err != nil && strings.Contains(err.Error(), \"failed to create repository manager client\") {\n    return fmt.Errorf(\"check gcloud auth / network to googleapis.com: %w\", err)\n}","preventionTips":["Set GOOGLE_APPLICATION_CREDENTIALS or run gcloud auth application-default login before invoking.","Verify outbound access to repositorymanager.googleapis.com in CI.","Keep contexts short-lived and free of pre-set deadlines when creating clients."],"tags":["gcp","auth","cloud-build","client"],"backgroundTag":"google-api-auth-failed","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"}