{"record":{"id":"b7db1ee2396a4f04","repo":"googleapis/mcp-toolbox","slug":"failed-to-create-logadmin-client-for-project-q","errorCode":null,"errorMessage":"failed to create logadmin client for project %q: %w","messagePattern":"failed to create logadmin client for project %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/cloudloggingadmin/cloud_logging_admin.go","lineNumber":425,"sourceCode":"}\n\nfunc initLogAdminConnectionWithOAuthToken(\n\tctx context.Context,\n\ttracer trace.Tracer,\n\tproject, name, userAgent, tokenString string,\n) (*logadmin.Client, error) {\n\tctx, span := sources.InitConnectionSpan(ctx, tracer, SourceType, name)\n\tdefer span.End()\n\n\ttoken := &oauth2.Token{\n\t\tAccessToken: string(tokenString),\n\t}\n\tts := oauth2.StaticTokenSource(token)\n\n\t// Initialize the logadmin client with tokenSource\n\tclient, err := logadmin.NewClient(ctx, project, option.WithUserAgent(userAgent), option.WithTokenSource(ts))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create logadmin client for project %q: %w\", project, err)\n\t}\n\treturn client, nil\n}\n\nfunc newLogAdminClientCreator(\n\tctx context.Context,\n\ttracer trace.Tracer,\n\tproject, name string,\n) (LogAdminClientCreator, error) {\n\tuserAgent, err := util.UserAgentFromContext(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn func(tokenString string) (*logadmin.Client, error) {\n\t\treturn initLogAdminConnectionWithOAuthToken(ctx, tracer, project, name, userAgent, tokenString)\n\t}, nil\n}","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/cloudloggingadmin/cloud_logging_admin.go#L407-L443","documentation":"This error wraps failures from logadmin.NewClient when building a Cloud Logging client using a user-supplied OAuth token via oauth2.StaticTokenSource. It is thrown by initLogAdminConnectionWithOAuthToken, so the root cause is almost always transport/option problems rather than credential lookup, since the token source is provided statically.","triggerScenarios":"Calling the OAuth-token path of client creation where logadmin.NewClient(ctx, project, option.WithUserAgent(...), option.WithTokenSource(ts)) fails — e.g. transport dial failure or invalid project string.","commonSituations":"Network/proxy blocking googleapis.com; invalid or empty project ID; SDK version incompatibilities building the gRPC client; expired/static access token surfaced later at request time rather than at client creation.","solutions":["Inspect the wrapped %w error for the transport-level cause","Verify the project ID is a valid GCP project string","Check network/proxy access to logging.googleapis.com","Verify the supplied access token is a fresh, valid OAuth2 token for the Logging scope"],"exampleFix":"// before\nclient, err := logadmin.NewClient(ctx, \"\", option.WithTokenSource(ts)) // empty project\n// after\nclient, err := logadmin.NewClient(ctx, \"my-gcp-project\", option.WithUserAgent(userAgent), option.WithTokenSource(ts))","handlingStrategy":"validation","validationCode":"if project == \"\" { return fmt.Errorf(\"project ID required\") }\nif token == \"\" || strings.Count(token, \".\") != 2 {\n    return fmt.Errorf(\"access token missing or not a JWT\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    return fmt.Errorf(\"logadmin client (oauth) init failed: %w\", err)\n}","preventionTips":["Refresh access tokens before expiry instead of reusing static ones","Verify the token includes the logging scopes","Confirm outbound network access to googleapis.com","Validate project ID before client construction"],"tags":["gcp","cloud-logging","oauth","go"],"backgroundTag":"oauth-token-invalid","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"}