{"record":{"id":"fe4e7712c6fae02f","repo":"googleapis/mcp-toolbox","slug":"unable-to-create-new-client-w","errorCode":null,"errorMessage":"unable to create new client: %w","messagePattern":"unable to create new client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/spanner/spanner.go","lineNumber":217,"sourceCode":"\treturn results, nil\n}\n\nfunc initSpannerClient(ctx context.Context, tracer trace.Tracer, name, project, instance, dbname string) (*spanner.Client, error) {\n\t//nolint:all // Reassigned ctx\n\tctx, span := sources.InitConnectionSpan(ctx, tracer, SourceType, name)\n\tdefer span.End()\n\n\t// Configure the connection to the database\n\tdb := fmt.Sprintf(\"projects/%s/instances/%s/databases/%s\", project, instance, dbname)\n\n\t// Create spanner client\n\tuserAgent, err := util.UserAgentFromContext(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tclient, err := spanner.NewClientWithConfig(ctx, db, spanner.ClientConfig{UserAgent: userAgent})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create new client: %w\", err)\n\t}\n\n\treturn client, nil\n}\n\nfunc (s *Source) InvokeSearchCatalog(ctx context.Context, params map[string]any, tokenStr string) ([]searchcatalog.DataplexSearchResponse, error) {\n\ttypeMap := map[string]string{\n\t\t\"cloud-spanner-instance\": \"SERVICE\",\n\t\t\"cloud-spanner-database\": \"DATABASE\",\n\t\t\"cloud-spanner-table\":    \"TABLE\",\n\t\t\"cloud-spanner-view\":     \"VIEW\",\n\t}\n\treturn searchcatalog.InvokeSearchCatalog(\n\t\tctx,\n\t\tparams,\n\t\ttokenStr,\n\t\t\"CLOUD_SPANNER\",\n\t\t\"databaseIds\",","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/spanner/spanner.go#L199-L235","documentation":"initSpannerClient (internal/sources/spanner/spanner.go:217) calls spanner.NewClientWithConfig to build a database client. Failure here — typically from connectivity, authentication, or an invalid database path — is wrapped as \"unable to create new client\". The client is created during source Initialize, so this error usually surfaces at server/toolbox startup.","triggerScenarios":"Calling Initialize for the Spanner source where spanner.NewClientWithConfig fails: wrong project/instance/database in the DSN, missing Application Default Credentials, network egress blocked, or the database does not exist.","commonSituations":"Misconfigured project/instance/db names in the toolbox config; GOOGLE_APPLICATION_CREDENTIALS unset or pointing to a bad keyfile; running on-prem without access to Google APIs; typo in database path format projects/p/instances/i/databases/d.","solutions":["Verify the database path format: projects/<proj>/instances/<inst>/database/<db> fields all exist","Authenticate: run `gcloud auth application-default login` or set GOOGLE_APPLICATION_CREDENTIALS to a valid service-account key","Confirm the project/instance/database exist via `gcloud spanner databases list --instance=<inst>`","Check network/DNS egress to spanner.googleapis.com:443","Enable the Spanner Admin/Data APIs on the project"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// pre-flight before Initialize\nmatches := regexp.MustCompile(`^projects/[^/]+/instances/[^/]+/databases/[^/]+$`).FindString(dsn)\nif matches == \"\" { log.Fatal(\"invalid spanner database path\") }\nif os.Getenv(\"GOOGLE_APPLICATION_CREDENTIALS\") == \"\" { log.Fatal(\"no ADC credentials configured\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the database path format at config load time","Run gcloud auth application-default login in dev environments","Enable the Spanner API before first use","Smoke-test connectivity: gcloud spanner databases describe <db> --instance=<inst>"],"tags":["spanner","client-init","authentication"],"backgroundTag":"database-client-init-failed","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"}