{"record":{"id":"6253475d3336a2c8","repo":"googleapis/mcp-toolbox","slug":"failed-to-verify-alloweddataset-s-in-project","errorCode":null,"errorMessage":"failed to verify allowedDataset '%s' in project '%s': %w","messagePattern":"failed to verify allowedDataset '(.+?)' in project '(.+?)': %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/bigquery/bigquery.go","lineNumber":247,"sourceCode":"\t\t\t\t}\n\t\t\t\tprojectID = parts[0]\n\t\t\t\tdatasetID = parts[1]\n\t\t\t\tallowedFullID = allowed\n\t\t\t} else {\n\t\t\t\tprojectID = r.Project\n\t\t\t\tdatasetID = allowed\n\t\t\t\tallowedFullID = fmt.Sprintf(\"%s.%s\", projectID, datasetID)\n\t\t\t}\n\n\t\t\tif s.Client != nil {\n\t\t\t\tdataset := s.Client.DatasetInProject(projectID, datasetID)\n\t\t\t\t_, err := dataset.Metadata(ctx)\n\t\t\t\tif err != nil {\n\t\t\t\t\ts.Client.Close()\n\t\t\t\t\tif gerr, ok := err.(*googleapi.Error); ok && gerr.Code == http.StatusNotFound {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"allowedDataset '%s' not found in project '%s'\", datasetID, projectID)\n\t\t\t\t\t}\n\t\t\t\t\treturn nil, fmt.Errorf(\"failed to verify allowedDataset '%s' in project '%s': %w\", datasetID, projectID, err)\n\t\t\t\t}\n\t\t\t}\n\t\t\tallowedDatasets[allowedFullID] = struct{}{}\n\t\t}\n\t}\n\n\ts.AllowedDatasets = allowedDatasets\n\ts.SessionProvider = s.newBigQuerySessionProvider()\n\ts.makeDataplexCatalogClient = s.lazyInitDataplexClient(ctx, tracer)\n\treturn s, nil\n}\n\n// setupClientCaching initializes caches and wraps the base client creator with caching logic.\nfunc setupClientCaching(s *Source, baseCreator BigqueryClientCreator) {\n\t// Define eviction handlers\n\tonBqEvict := func(key string, value interface{}) {\n\t\tif client, ok := value.(*bigqueryapi.Client); ok && client != nil {\n\t\t\tclient.Close()","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/bigquery/bigquery.go#L229-L265","documentation":"This is the non-404 branch of the allowedDataset verification: when dataset.Metadata fails with any error other than googleapi 404 (network failure, 403 permission errors, 500s, quota issues), initialization aborts and wraps the underlying error with this message. The client is closed before returning.","triggerScenarios":"Verifying an allowedDataset when the BigQuery API call fails transiently or permanently for reasons other than not-found: connectivity/DNS issues, 403 denied, API not enabled on the project, rate limiting, or invalid project causing non-404 API errors.","commonSituations":"Network egress blocked in the deployment environment; BigQuery API disabled in the target project; service account lacking any BigQuery permission producing 403; transient backend errors during startup.","solutions":["Inspect the wrapped underlying error for the real cause (403 vs network vs 5xx).","Ensure the BigQuery API (bigquery.googleapis.com) is enabled on the project.","Fix connectivity/egress to googleapis.com (proxies, VPC, firewall rules).","Grant the credentials basic BigQuery permissions so metadata lookups aren't denied.","Retry initialization if the failure was transient (5xx/rate limit)."],"exampleFix":"// before (no connectivity check)\n./toolbox\n// after\ngcloud services list --enabled | grep bigquery\ncurl -sI https://bigquery.googleapis.com && ./toolbox","handlingStrategy":"retry","validationCode":"if _, err := bqClient.DatasetInProject(proj, name).Metadata(ctx); err != nil {\n\tvar gerr *googleapi.Error\n\tif !errors.As(err, &gerr) || gerr.Code != http.StatusNotFound {\n\t\tlog.Printf(\"pre-flight metadata check failed (non-404): %v\", err)\n\t}\n}","typeGuard":"func isNotFound(err error) bool {\n\tvar gerr *googleapi.Error\n\treturn errors.As(err, &gerr) && gerr.Code == 404\n}","tryCatchPattern":"src, err := sourceRegistry.Initialize(ctx, cfg)\nif err != nil {\n\tif strings.Contains(err.Error(), \"failed to verify allowedDataset\") {\n\t\tif isTransient(err) { // network/5xx\n\t\t\treturn retryWithBackoff(func() error { return initializeSource(ctx, cfg) }, 3)\n\t\t}\n\t\tlog.Printf(\"permanent metadata failure, check API enablement and permissions: %v\", err)\n\t}\n\treturn err\n}","preventionTips":["Enable the BigQuery API on the target project beforehand.","Ensure egress to bigquery.googleapis.com from the deployment environment.","Grant the identity minimal BigQuery metadata permissions to avoid 403s.","Retry startup on transient 5xx/rate-limit errors with backoff."],"tags":["bigquery","network","gcp","permissions","api"],"backgroundTag":"api-request-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"}