{"record":{"id":"bd8d662d098f428d","repo":"googleapis/mcp-toolbox","slug":"alloweddataset-s-not-found-in-project-s","errorCode":null,"errorMessage":"allowedDataset '%s' not found in project '%s'","messagePattern":"allowedDataset '(.+?)' not found in project '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/bigquery/bigquery.go","lineNumber":245,"sourceCode":"\t\t\t\tif len(parts) != 2 {\n\t\t\t\t\treturn nil, fmt.Errorf(\"invalid allowedDataset format: %q, expected 'project.dataset' or 'dataset'\", allowed)\n\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{}) {","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/bigquery/bigquery.go#L227-L263","documentation":"During Initialize, the source verifies each allowedDataset exists by fetching its metadata via the BigQuery client (dataset.Metadata). If the API returns HTTP 404 (googleapi.Error), the dataset (or project) does not exist or is not visible to the credentials, producing this error and aborting initialization.","triggerScenarios":"allowedDatasets entry naming a dataset that doesn't exist, a dataset in a different project than assumed, or one the ADC/service account cannot see (404 is also returned for permission-hidden resources in BigQuery).","commonSituations":"Typos in dataset names; referencing datasets in another project without the 'project.' prefix so they resolve against the wrong project; service account lacking BigQuery Data Viewer on the dataset; deleted datasets still listed in config.","solutions":["Verify the dataset exists: `bq ls --project_id=<project>` or the Cloud Console.","Prefix the entry with the owning project ('project.dataset') if it is not in the source's project.","Grant the configured credentials BigQuery Data Viewer (roles/bigquery.dataViewer) on the dataset — permission gaps surface as 404.","Check for typos and case sensitivity in the dataset name."],"exampleFix":"// before\nallowedDatasets:\n  - analytics   # dataset lives in another project\n// after\nallowedDatasets:\n  - my-gcp-project.analytics","handlingStrategy":"validation","validationCode":"for _, ds := range allowedDatasets {\n\tproj, name := splitProjectDataset(ds, cfg.Project)\n\tif _, err := bqClient.DatasetInProject(proj, name).Metadata(ctx); err != nil {\n\t\tlog.Printf(\"warning: allowedDataset %s in project %s is not visible: %v\", name, proj, err)\n\t}\n}","typeGuard":null,"tryCatchPattern":"src, err := sourceRegistry.Initialize(ctx, cfg)\nif err != nil {\n\tif strings.Contains(err.Error(), \"not found in project\") {\n\t\tlog.Printf(\"dataset missing or hidden; verify existence and grants: %v\", err)\n\t\treturn err\n\t}\n\treturn err\n}","preventionTips":["Verify datasets exist with `bq ls` or the console before adding them to config.","Fully qualify cross-project datasets as project.dataset.","Grant roles/bigquery.dataViewer on each allowed dataset to the configured identity (404 can mean hidden).","Prune deleted datasets from config during environment cleanup."],"tags":["bigquery","gcp","not-found","config","permissions"],"backgroundTag":"dataset-not-found","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"}