{"record":{"id":"bc4326f4e41d7b37","repo":"googleapis/mcp-toolbox","slug":"unable-to-create-client-w","errorCode":null,"errorMessage":"unable to create client: %w","messagePattern":"unable to create client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/sources/bigtable/bigtable.go","lineNumber":63,"sourceCode":"\t}\n\treturn actual, nil\n}\n\ntype Config struct {\n\tName     string `yaml:\"name\" validate:\"required\"`\n\tType     string `yaml:\"type\" validate:\"required\"`\n\tProject  string `yaml:\"project\" validate:\"required\"`\n\tInstance string `yaml:\"instance\" validate:\"required\"`\n}\n\nfunc (r Config) SourceConfigType() string {\n\treturn SourceType\n}\n\nfunc (r Config) Initialize(ctx context.Context, tracer trace.Tracer) (sources.Source, error) {\n\tclient, err := initBigtableClient(ctx, tracer, r.Name, r.Project, r.Instance)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create client: %w\", err)\n\t}\n\n\tinstanceAdminClient, err := initBigtableInstanceAdminClient(ctx, tracer, r.Name, r.Project)\n\tif err != nil {\n\t\tclient.Close()\n\t\treturn nil, fmt.Errorf(\"unable to create instance admin client: %w\", err)\n\t}\n\n\tadminClient, err := initBigtableAdminClient(ctx, tracer, r.Name, r.Project, r.Instance)\n\tif err != nil {\n\t\tclient.Close()\n\t\tinstanceAdminClient.Close()\n\t\treturn nil, fmt.Errorf(\"unable to create admin client: %w\", err)\n\t}\n\n\ts := &Source{\n\t\tConfig:        r,\n\t\tClient:        client,","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/bigtable/bigtable.go#L45-L81","documentation":"Config.Initialize fails when initBigtableClient cannot construct the Bigtable data client (cloud.google.com/go/bigtable.NewClient). Causes include invalid project/instance IDs, missing or invalid Application Default Credentials, unreachable Google endpoints, or unsupported configuration. The data client is not created, so the source cannot start.","triggerScenarios":"Source initialization (toolbox startup with a bigtable source config) when: r.Project or r.Instance is empty/malformed, ADC are absent (no GOOGLE_APPLICATION_CREDENTIALS, no metadata server), token fetching fails, or the underlying NewClient RPC to list the instance returns an error.","commonSituations":"First-time local setup without gcloud auth application-default login; wrong project ID in YAML config; running outside GCP without a service-account key file; VPC/DMZ network blocking googleapis.com; deleted instance still referenced in config.","solutions":["Set valid credentials: export GOOGLE_APPLICATION_CREDENTIALS=/path/to/sa.json or run gcloud auth application-default login","Verify project and instance fields in the toolbox config against gcloud config list / gcloud bigtable instances list","Check network egress to *.googleapis.com (oauth2.googleapis.com, bigtable.googleapis.com)","Fix the wrapped error by inspecting it: it contains the precise reason (credential, permission, or not-found)"],"exampleFix":"// before: source config missing instance\nkind: bigtable\nproject: my-project\n// after: complete config with credentials available\nkind: bigtable\nproject: my-project\ninstance: my-instance\n// plus: gcloud auth application-default login","handlingStrategy":"validation","validationCode":"// run before starting the toolbox\nfunc precheckBigtable(ctx context.Context, project, instance string) error {\n    if project == \"\" || instance == \"\" {\n        return fmt.Errorf(\"bigtable source requires non-empty project and instance; got project=%q instance=%q\", project, instance)\n    }\n    creds, err := google.FindDefaultCredentials(ctx, bigtable.Scope)\n    if err != nil {\n        return fmt.Errorf(\"no ADC found: set GOOGLE_APPLICATION_CREDENTIALS or run 'gcloud auth application-default login': %w\", err)\n    }\n    return nil\n}","typeGuard":"func isAuthError(err error) bool {\n    c := status.Code(errors.Unwrap(err))\n    return c == codes.Unauthenticated || c == codes.PermissionDenied\n}","tryCatchPattern":"src, err := cfg.Initialize(ctx, tracer)\nif err != nil {\n    var preErr error\n    if errors.Unwrap(err) != nil { preErr = errors.Unwrap(err) }\n    if preErr != nil && isAuthError(preErr) {\n        return fmt.Errorf(\"fix credentials (GOOGLE_APPLICATION_CREDENTIALS / gcloud auth): %w\", err)\n    }\n    return err\n}","preventionTips":["Always set GOOGLE_APPLICATION_CREDENTIALS or run gcloud auth application-default login before starting the toolbox locally","Copy project/instance IDs directly from gcloud bigtable instances list output","Run the credential precheck (google.FindDefaultCredentials) in CI before deploying","Verify network egress to bigtable.googleapis.com and oauth2.googleapis.com"],"tags":["gcp","bigtable","authentication","configuration"],"backgroundTag":"missing-gcp-credentials","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}