{"record":{"id":"050bc7afa4150629","repo":"weaviate/weaviate","slug":"create-client","errorCode":null,"errorMessage":"create client","messagePattern":"create client","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"modules/backup-gcs/client.go","lineNumber":148,"sourceCode":"\treturn projectID\n}\n\nfunc newClient(ctx context.Context, config *clientConfig, dataPath string, logger logrus.FieldLogger) (*gcsClient, error) {\n\topts, err := storageOptions(ctx, logger, config.Transport)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar client *storage.Client\n\tif config.Transport.UseGRPCOrDefault() {\n\t\tlogger.Infof(\"backup-gcs: using gRPC transport with a connection pool of %d per client\", config.Transport.GRPCConnPool)\n\t\tclient, err = storage.NewGRPCClient(ctx, opts...)\n\t} else {\n\t\tlogger.Info(\"backup-gcs: using HTTP transport\")\n\t\tclient, err = storage.NewClient(ctx, opts...)\n\t}\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"create client\")\n\t}\n\n\tclient.SetRetry(\n\t\tstorage.WithBackoff(gax.Backoff{\n\t\t\tInitial:    2 * time.Second, // Note: the client uses a jitter internally\n\t\t\tMax:        60 * time.Second,\n\t\t\tMultiplier: 3,\n\t\t}),\n\t\tstorage.WithPolicy(storage.RetryAlways),\n\t\tstorage.WithErrorFunc(gcpcommon.RetryErrorFunc),\n\t)\n\tnodeID, err := os.Hostname()\n\tif err != nil {\n\t\tnodeID = strconv.Itoa(os.Getpid())\n\t}\n\treturn &gcsClient{client: client, config: *config, projectID: projectID(), dataPath: dataPath, logger: logger, nodeID: nodeID}, nil\n}\n","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/modules/backup-gcs/client.go#L130-L166","documentation":"This error is wrapped by errors.Wrap(err, \"create client\") in newClient (modules/backup-gcs/client.go:148) when either storage.NewGRPCClient or storage.NewClient from cloud.google.com/go/storage fails to construct a GCS client. The underlying error comes from the Google Cloud Storage Go SDK and almost always means credentials could not be found or were invalid, the project ID could not be resolved, or (for gRPC transport) the connection could not be established. No network call to GCS has succeeded at this point — module initialization (Init) aborts.","triggerScenarios":"Weaviate starts with the backup-gcs module enabled and calls newClient during Init; storage.NewClient/NewGRPCClient fails because GOOGLE_APPLICATION_CREDENTIALS points to a missing/invalid JSON key, no Application Default Credentials exist in the environment (no metadata server when running outside GCP), the credentials lack storage scope, or transport settings are inconsistent.","commonSituations":"Running Weaviate on-prem/Docker without mounting the service-account key file; GOOGLE_APPLICATION_CREDENTIALS typo or wrong path; stale/revoked service-account key; running on GKE without the proper service account attached; forcing gRPC transport (BACKUP_GCS_USE_GRPC) in an environment where gRPC to storage.googleapis.com is blocked by a proxy.","solutions":["Set GOOGLE_APPLICATION_CREDENTIALS to the absolute path of a valid service-account JSON key and ensure the file is mounted into the container.","If running outside GCP, use workload identity (GKE) or attach a service account; alternatively pass credentials via storage option in clientConfig.","Validate the key file with: gcloud auth application-default login (local) or gcloud auth activate-service-account --key-file=... .","If a corporate proxy blocks gRPC, set the transport to HTTP (BACKUP_GCS_USE_GRPC=false) so storage.NewClient is used instead.","Check the wrapped inner error text — 'could not find default credentials' vs 'google: could not refresh token' — to distinguish credential discovery from token refresh failures."],"exampleFix":"// before\ndocker run weaviate/weaviate ... (no credentials mounted)\n// after\ndocker run -v /secrets/gcs-key.json:/secrets/gcs-key.json \\\n  -e GOOGLE_APPLICATION_CREDENTIALS=/secrets/gcs-key.json \\\n  -e BACKUP_GCS_BUCKET=my-backup-bucket weaviate/weaviate","handlingStrategy":"validation","validationCode":"// Before enabling backup-gcs, verify ADC resolves and the bucket is reachable:\ncreds, err := google.FindDefaultCredentials(ctx, storage.ScopeFullControl)\nif err != nil {\n    return fmt.Errorf(\"GCS credentials not configured: %w\", err)\n}\nclient, err := storage.NewClient(ctx, option.WithCredentials(creds))\nif err != nil {\n    return fmt.Errorf(\"GCS client creation failed: %w\", err)\n}\n_, err = client.Bucket(os.Getenv(\"BACKUP_GCS_BUCKET\")).\n    Objects(ctx, &storage.Query{MaxResults: 1}).Next()","typeGuard":null,"tryCatchPattern":"if err != nil {\n    var terr *googleapi.Error\n    if errors.As(err, &terr) {\n        log.Printf(\"GCS init API error %d: %v\", terr.Code, terr)\n    } else {\n        log.Printf(\"GCS init failed (check GOOGLE_APPLICATION_CREDENTIALS): %v\", err)\n    }\n    return err // module cannot function without a client\n}","preventionTips":["Mount the service-account key and set GOOGLE_APPLICATION_CREDENTIALS in every environment (compose, k8s) before enabling the module.","Use workload identity on GKE instead of key files to eliminate credential-discovery failures.","Smoke-test with `gcloud auth application-default print-access-token` in the same container image/env.","Keep transport (gRPC vs HTTP) consistent with network egress rules; prefer HTTP behind strict HTTP-only proxies."],"tags":["gcs","authentication","cloud-storage","configuration","go"],"backgroundTag":"gcp-default-credentials-not-found","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}