{"record":{"id":"8da5661462cb640c","repo":"googleapis/mcp-toolbox","slug":"dataset-level-operations-like-s-s-are-not-allo","errorCode":null,"errorMessage":"dataset-level operations like '%s %s' are not allowed when dataset restrictions are in place","messagePattern":"dataset-level operations like '(.+?) (.+?)' are not allowed when dataset restrictions are in place","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/bigquery/bigquerycommon/table_name_parser.go","lineNumber":281,"sourceCode":"\t\t\t\t\tcase \"call\":\n\t\t\t\t\t\treturn 0, fmt.Errorf(\"CALL is not allowed when dataset restrictions are in place, as the called procedure's contents cannot be safely analyzed\")\n\t\t\t\t\tcase \"immediate\":\n\t\t\t\t\t\tif lastToken == \"execute\" {\n\t\t\t\t\t\t\treturn 0, fmt.Errorf(\"EXECUTE IMMEDIATE is not allowed when dataset restrictions are in place, as its contents cannot be safely analyzed\")\n\t\t\t\t\t\t}\n\t\t\t\t\tcase \"procedure\", \"function\":\n\t\t\t\t\t\tif lastToken == \"create\" || lastToken == \"create or replace\" {\n\t\t\t\t\t\t\treturn 0, fmt.Errorf(\"unanalyzable statements like '%s %s' are not allowed\", strings.ToUpper(lastToken), strings.ToUpper(keyword))\n\t\t\t\t\t\t}\n\t\t\t\t\tcase verbCreate, verbAlter, verbDrop, verbSelect, verbInsert, verbUpdate, verbDelete, verbMerge:\n\t\t\t\t\t\tif statementVerb == \"\" {\n\t\t\t\t\t\t\tstatementVerb = keyword\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif statementVerb == verbCreate || statementVerb == verbAlter || statementVerb == verbDrop {\n\t\t\t\t\t\tif keyword == \"schema\" || keyword == \"dataset\" {\n\t\t\t\t\t\t\treturn 0, fmt.Errorf(\"dataset-level operations like '%s %s' are not allowed when dataset restrictions are in place\", strings.ToUpper(statementVerb), strings.ToUpper(keyword))\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif _, ok := tableFollowsKeywords[keyword]; ok {\n\t\t\t\t\t\texpectingTable = true\n\t\t\t\t\t\tlastTableKeyword = keyword\n\t\t\t\t\t} else if _, ok := tableContextExitKeywords[keyword]; ok {\n\t\t\t\t\t\texpectingTable = false\n\t\t\t\t\t\tlastTableKeyword = \"\"\n\t\t\t\t\t}\n\t\t\t\t\tif lastToken == \"create\" && keyword == \"or\" {\n\t\t\t\t\t\tlastToken = \"create or\"\n\t\t\t\t\t} else if lastToken == \"create or\" && keyword == \"replace\" {\n\t\t\t\t\t\tlastToken = \"create or replace\"\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlastToken = keyword\n\t\t\t\t\t}\n\t\t\t\t} else if len(parts) >= 2 {","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/bigquery/bigquerycommon/table_name_parser.go#L263-L299","documentation":"Under dataset restrictions, parseSQL rejects dataset/schema-level DDL (CREATE/ALTER/DROP SCHEMA or DATASET) because such operations act on entire datasets and cannot be validated against an allowed-tables analysis. This prevents a restricted user from creating, modifying, or deleting whole datasets.","triggerScenarios":"Submitting a statement whose verb is CREATE, ALTER, or DROP followed by the keyword 'schema' or 'dataset' through TableParser/parseSQL with dataset restrictions enabled.","commonSituations":"Migration scripts that create or drop datasets; automated jobs doing CREATE SCHEMA IF NOT EXISTS; users confusing dataset-scoped admin work with normal queries.","solutions":["Remove the dataset-level DDL statement from the restricted query path","Perform dataset create/alter/drop with an admin credential outside dataset restrictions","Pre-create the dataset manually, then run only table-level statements through the restricted tool"],"exampleFix":"// before\nCREATE SCHEMA proj.new_ds;\nSELECT * FROM proj.ds.t;\n// after\n-- create dataset via admin tooling first, then:\nSELECT * FROM proj.ds.t;","handlingStrategy":"validation","validationCode":"verbs := []string{\"CREATE\", \"ALTER\", \"DROP\"}\nobjects := []string{\"SCHEMA\", \"DATASET\"}\nu := strings.ToUpper(sql)\nfor _, v := range verbs {\n    for _, o := range objects {\n        if strings.Contains(u, v+\" \"+o) {\n            return fmt.Errorf(\"query rejected: %s %s requires unrestricted access\", v, o)\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"_, err := parser.Parse(sql)\nif err != nil && strings.Contains(err.Error(), \"dataset-level operations\") {\n    // escalate to an admin workflow or reject with a clear message\n    return err\n}","preventionTips":["Manage dataset lifecycle (create/alter/drop) outside restricted query tools","Use dedicated admin credentials for dataset DDL","Pre-create datasets in infrastructure-as-code instead of at query time"],"tags":["bigquery","sql-parsing","dataset-restrictions","ddl"],"backgroundTag":"dataset-ddl-blocked","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"}