{"record":{"id":"1d0d3a0928052f21","repo":"googleapis/mcp-toolbox","slug":"query-contains-table-s-without-project-id-and","errorCode":null,"errorMessage":"query contains table '%s' without project ID, and no default project ID is provided","messagePattern":"query contains table '(.+?)' without project ID, and no default project ID is provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/bigquery/bigquerycommon/table_name_parser.go","lineNumber":473,"sourceCode":"\t\t}\n\t\ttotalConsumed++\n\t}\n\treturn parts, totalConsumed, nil\n}\n\nfunc formatTableID(parts []string, defaultProjectID string) (string, error) {\n\tif len(parts) < 2 || len(parts) > 3 {\n\t\t// Not a table identifier (could be a CTE, column, etc.).\n\t\t// Return the consumed length so the main loop can skip this identifier.\n\t\treturn \"\", nil\n\t}\n\n\tvar tableID string\n\tif len(parts) == 3 { // project.dataset.table\n\t\ttableID = strings.Join(parts, \".\")\n\t} else { // dataset.table\n\t\tif defaultProjectID == \"\" {\n\t\t\treturn \"\", fmt.Errorf(\"query contains table '%s' without project ID, and no default project ID is provided\", strings.Join(parts, \".\"))\n\t\t}\n\t\ttableID = fmt.Sprintf(\"%s.%s\", defaultProjectID, strings.Join(parts, \".\"))\n\t}\n\n\treturn tableID, nil\n}\n","sourceCodeStart":455,"sourceCodeEnd":480,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/bigquery/bigquerycommon/table_name_parser.go#L455-L480","documentation":"formatTableID builds fully-qualified project.dataset.table IDs so table access can be checked against dataset restrictions. A reference with only dataset.table cannot be resolved without a default project; if no defaultProjectID was supplied to the parser, it fails rather than guessing the project.","triggerScenarios":"parseSQL encounters a dataset.table (2-part) reference while TableParser was constructed with an empty defaultProjectID (e.g. no project passed from the source config).","commonSituations":"Source configured without a BigQuery project ID while queries use unqualified table names; shared SQL written assuming a default project; environment-dependent configs where the default project is unset in prod.","solutions":["Configure the BigQuery source with a project ID so the parser has a defaultProjectID","Fully qualify table references as project.dataset.table in the query","Pass a default project when constructing the TableParser"],"exampleFix":"// before\nTableParser{DefaultProjectID: \"\"} with query: SELECT * FROM mydataset.mytable\n// after\nTableParser{DefaultProjectID: \"my-project\"} -- or query:\nSELECT * FROM my-project.mydataset.mytable","handlingStrategy":"validation","validationCode":"if parser.DefaultProjectID == \"\" && usesTwoPartTableName(sql) {\n    return fmt.Errorf(\"source has no default project; fully qualify tables as project.dataset.table\")\n}","typeGuard":null,"tryCatchPattern":"tables, err := parser.Parse(sql)\nif err != nil && strings.Contains(err.Error(), \"no default project ID\") {\n    // re-parse with an explicit default project, or ask user to qualify tables\n    return err\n}","preventionTips":["Always configure a project ID on the BigQuery source","Write fully-qualified project.dataset.table references in shared SQL","Assert a non-empty project ID at server startup in tests"],"tags":["bigquery","sql-parsing","configuration","project-id"],"backgroundTag":"missing-default-project","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"}