weaviate/weaviate · critical

create client

Error message

create client

What it means

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.

Solutions

  1. Set GOOGLE_APPLICATION_CREDENTIALS to the absolute path of a valid service-account JSON key and ensure the file is mounted into the container.
  2. If running outside GCP, use workload identity (GKE) or attach a service account; alternatively pass credentials via storage option in clientConfig.
  3. Validate the key file with: gcloud auth application-default login (local) or gcloud auth activate-service-account --key-file=... .
  4. If a corporate proxy blocks gRPC, set the transport to HTTP (BACKUP_GCS_USE_GRPC=false) so storage.NewClient is used instead.
  5. 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.

Example fix

// before
docker run weaviate/weaviate ... (no credentials mounted)
// after
docker run -v /secrets/gcs-key.json:/secrets/gcs-key.json \
  -e GOOGLE_APPLICATION_CREDENTIALS=/secrets/gcs-key.json \
  -e BACKUP_GCS_BUCKET=my-backup-bucket weaviate/weaviate
Defensive patterns

Strategy: validation

Validate before calling

// Before enabling backup-gcs, verify ADC resolves and the bucket is reachable:
creds, err := google.FindDefaultCredentials(ctx, storage.ScopeFullControl)
if err != nil {
    return fmt.Errorf("GCS credentials not configured: %w", err)
}
client, err := storage.NewClient(ctx, option.WithCredentials(creds))
if err != nil {
    return fmt.Errorf("GCS client creation failed: %w", err)
}
_, err = client.Bucket(os.Getenv("BACKUP_GCS_BUCKET")).
    Objects(ctx, &storage.Query{MaxResults: 1}).Next()

Try / catch

if err != nil {
    var terr *googleapi.Error
    if errors.As(err, &terr) {
        log.Printf("GCS init API error %d: %v", terr.Code, terr)
    } else {
        log.Printf("GCS init failed (check GOOGLE_APPLICATION_CREDENTIALS): %v", err)
    }
    return err // module cannot function without a client
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/050bc7afa4150629. Report an issue: GitHub.

Appendix: source

Thrown at modules/backup-gcs/client.go:148

	return projectID
}

func newClient(ctx context.Context, config *clientConfig, dataPath string, logger logrus.FieldLogger) (*gcsClient, error) {
	opts, err := storageOptions(ctx, logger, config.Transport)
	if err != nil {
		return nil, err
	}

	var client *storage.Client
	if config.Transport.UseGRPCOrDefault() {
		logger.Infof("backup-gcs: using gRPC transport with a connection pool of %d per client", config.Transport.GRPCConnPool)
		client, err = storage.NewGRPCClient(ctx, opts...)
	} else {
		logger.Info("backup-gcs: using HTTP transport")
		client, err = storage.NewClient(ctx, opts...)
	}
	if err != nil {
		return nil, errors.Wrap(err, "create client")
	}

	client.SetRetry(
		storage.WithBackoff(gax.Backoff{
			Initial:    2 * time.Second, // Note: the client uses a jitter internally
			Max:        60 * time.Second,
			Multiplier: 3,
		}),
		storage.WithPolicy(storage.RetryAlways),
		storage.WithErrorFunc(gcpcommon.RetryErrorFunc),
	)
	nodeID, err := os.Hostname()
	if err != nil {
		nodeID = strconv.Itoa(os.Getpid())
	}
	return &gcsClient{client: client, config: *config, projectID: projectID(), dataPath: dataPath, logger: logger, nodeID: nodeID}, nil
}

View on GitHub (pinned to 75aa4b6d11)