{"record":{"id":"514d22236fb29952","repo":"GoogleContainerTools/skaffold","slug":"statuscode-deploy-get-cloud-run-client-err","errorCode":"StatusCode_DEPLOY_GET_CLOUD_RUN_CLIENT_ERR","errorMessage":"unable to create Cloud Run Client","messagePattern":"unable to create Cloud Run Client","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/deploy/cloudrun/deploy.go","lineNumber":489,"sourceCode":"\tif err != nil {\n\t\treturn nil, sErrors.NewError(fmt.Errorf(\"error deploying Cloud Run WorkerPool: %s\", err), &proto.ActionableErr{\n\t\t\tMessage: err.Error(),\n\t\t\tErrCode: proto.StatusCode_DEPLOY_CLOUD_RUN_UPDATE_WORKER_POOL_ERR,\n\t\t})\n\t}\n\treturn &resName, nil\n}\n\nfunc (d *Deployer) cleanupRun(ctx context.Context, out io.Writer, dryRun bool, manifests manifest.ManifestList) error {\n\tvar errors []error\n\tcOptions := d.clientOptions\n\tif d.useGcpOptions {\n\t\tcOptions = append(cOptions, option.WithEndpoint(fmt.Sprintf(\"%s-run.googleapis.com\", d.Region)))\n\t\tcOptions = append(gcp.ClientOptions(ctx), cOptions...)\n\t}\n\tcrclient, err := run.NewService(ctx, cOptions...)\n\tif err != nil {\n\t\treturn sErrors.NewError(fmt.Errorf(\"unable to create Cloud Run Client\"), &proto.ActionableErr{\n\t\t\tMessage: err.Error(),\n\t\t\tErrCode: proto.StatusCode_DEPLOY_GET_CLOUD_RUN_CLIENT_ERR,\n\t\t})\n\t}\n\tfor _, manifest := range manifests {\n\t\ttpe, err := getTypeFromManifest(manifest)\n\t\tswitch {\n\t\tcase err != nil:\n\t\t\terrors = append(errors, err)\n\t\tcase tpe == typeService:\n\t\t\terr := d.deleteRunService(crclient, out, dryRun, manifest)\n\t\t\tif err != nil {\n\t\t\t\terrors = append(errors, err)\n\t\t\t}\n\t\tcase tpe == typeJob:\n\t\t\terr := d.deleteRunJob(crclient, out, dryRun, manifest)\n\t\t\tif err != nil {\n\t\t\t\terrors = append(errors, err)","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/deploy/cloudrun/deploy.go#L471-L507","documentation":"cleanupRun builds a Cloud Run API client via run.NewService(ctx, cOptions...) before deleting resources. If client construction fails (bad options, transport setup, credential initialization), this DEPLOY_GET_CLOUD_RUN_CLIENT_ERR is returned and cleanup cannot proceed.","triggerScenarios":"run.NewService returns an error: invalid option.WithEndpoint value (e.g. malformed region producing \"-run.googleapis.com\"), failure assembling gcp.ClientOptions (bad ADC/credentials), or nil/failed context deadline.","commonSituations":"Region left empty so the endpoint becomes \"-run.googleapis.com\"; no Application Default Credentials available (CI without GOOGLE_APPLICATION_CREDENTIALS); corrupted gcloud credentials; ctx cancelled before client creation.","solutions":["Verify the region is set in skaffold.yaml so the endpoint is a valid \"<region>-run.googleapis.com\"","Set up Application Default Credentials: `gcloud auth application-default login` or GOOGLE_APPLICATION_CREDENTIALS in CI","Check the context is not cancelled/expired before cleanup","Confirm gcloud configuration and network reachability to googleapis.com"],"exampleFix":"// before (skaffold.yaml missing region)\ndeploy:\n  cloudrun:\n    project: my-project\n// after\ndeploy:\n  cloudrun:\n    project: my-project\n    region: us-central1","handlingStrategy":"validation","validationCode":"func preflightCloudRunClient(region, project string) error {\n    if region == \"\" {\n        return fmt.Errorf(\"region must be set; endpoint would be \\\"-run.googleapis.com\\\"\")\n    }\n    creds, err := google.FindDefaultCredentials(context.Background(), run.CloudPlatformScope)\n    if err != nil {\n        return fmt.Errorf(\"no valid Application Default Credentials: %w\", err)\n    }\n    return nil\n}","typeGuard":"func canBuildClient(opts []option.ClientOption) bool {\n    _, err := run.NewService(context.Background(), opts...)\n    return err == nil\n}","tryCatchPattern":"err := deployer.Cleanup(ctx, out)\nif err != nil {\n    var actionErr *sErrors.Error\n    if errors.As(err, &actionErr) && actionErr.ErrCode == proto.StatusCode_DEPLOY_GET_CLOUD_RUN_CLIENT_ERR {\n        // fix credentials/region, then retry cleanup\n    }\n    return err\n}","preventionTips":["Always configure region in skaffold.yaml cloud-run deploy","Set up ADC via `gcloud auth application-default login` or service-account key in CI","Verify GOOGLE_APPLICATION_CREDENTIALS points to a valid key file","Ensure the context passed to cleanup is not already cancelled"],"tags":["cloud-run","client-init","credentials","gcp"],"backgroundTag":"client-initialization-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"}