{"record":{"id":"6f4967a9b13f1010","repo":"googleapis/mcp-toolbox","slug":"expected-alloweddataset-to-have-at-least-2-parts","errorCode":null,"errorMessage":"expected allowedDataset to have at least 2 parts (project.dataset): %s","messagePattern":"expected allowedDataset to have at least 2 parts \\(project\\.dataset\\): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/bigquery/bigqueryexecutesql/bigqueryexecutesql.go","lineNumber":279,"sourceCode":"// buildParams builds the tool's parameters from the source's write mode and allowed-dataset\n// configuration. Empty writeMode and a nil allow-list yield the plain skeleton.\nfunc buildParams(writeMode string, allowedDatasets []string) (parameters.Parameters, error) {\n\tvar sqlDescriptionBuilder strings.Builder\n\tswitch writeMode {\n\tcase bigqueryds.WriteModeBlocked:\n\t\tsqlDescriptionBuilder.WriteString(\"The SQL to execute. In 'blocked' mode, only SELECT statements are allowed; other statement types will fail.\")\n\tcase bigqueryds.WriteModeProtected:\n\t\tsqlDescriptionBuilder.WriteString(\"The SQL to execute. Only SELECT statements and writes to the session's temporary dataset are allowed (e.g., `CREATE TEMP TABLE ...`).\")\n\tdefault: // WriteModeAllowed\n\t\tsqlDescriptionBuilder.WriteString(\"The SQL to execute.\")\n\t}\n\n\tif len(allowedDatasets) > 0 {\n\t\tif len(allowedDatasets) == 1 {\n\t\t\tdatasetFQN := allowedDatasets[0]\n\t\t\tparts := strings.Split(datasetFQN, \".\")\n\t\t\tif len(parts) < 2 {\n\t\t\t\treturn nil, fmt.Errorf(\"expected allowedDataset to have at least 2 parts (project.dataset): %s\", datasetFQN)\n\t\t\t}\n\t\t\tdatasetID := parts[1]\n\t\t\tfmt.Fprintf(&sqlDescriptionBuilder, \" The query must only access the `%s` dataset. \"+\n\t\t\t\t\"To query a table within this dataset (e.g., `my_table`), \"+\n\t\t\t\t\"qualify it with the dataset id (e.g., `%s.my_table`).\", datasetFQN, datasetID)\n\t\t} else {\n\t\t\tdatasetIDs := []string{}\n\t\t\tfor _, ds := range allowedDatasets {\n\t\t\t\tdatasetIDs = append(datasetIDs, fmt.Sprintf(\"`%s`\", ds))\n\t\t\t}\n\t\t\tfmt.Fprintf(&sqlDescriptionBuilder, \" The query must only access datasets from the following list: %s.\", strings.Join(datasetIDs, \", \"))\n\t\t}\n\t}\n\n\tsqlParameter := parameters.NewStringParameter(\"sql\", sqlDescriptionBuilder.String())\n\tdryRunParameter := parameters.NewBooleanParameter(\n\t\t\"dry_run\",\n\t\t\"If set to true, the query will be validated and information about the execution will be returned \"+","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/bigquery/bigqueryexecutesql/bigqueryexecutesql.go#L261-L297","documentation":"buildParams for bigquery-execute-sql parses each entry in allowedDatasets, which must be a fully-qualified BigQuery dataset of the form project.dataset. When a single allowed dataset has no dot (fewer than 2 parts), the tool cannot construct the SQL-guard description and returns this error at Initialize/resolveParams time.","triggerScenarios":"Configuring allowedDatasets with a bare dataset id like 'my_dataset' (or a value with only whitespace/malformed qualifiers) instead of 'my-project.my_dataset', then initializing the tool.","commonSituations":"Copy-pasting a dataset id from the BigQuery console without the project prefix; assuming the source's default project is applied automatically; typos like a trailing dot or comma-separated values in one list element.","solutions":["Change the allowedDatasets entry to the fully-qualified form 'project.dataset' (e.g. my-project.my_dataset).","Check for typos such as missing dots, extra dots, or trailing whitespace in the config value.","If using multiple datasets, ensure every list element independently satisfies project.dataset format.","Re-run initialization; the error names the offending value to fix."],"exampleFix":"// before (tools.yaml)\nallowedDatasets:\n  - my_dataset\n// after\nallowedDatasets:\n  - my-project.my_dataset","handlingStrategy":"validation","validationCode":"for _, d := range cfg.AllowedDatasets {\n    if len(strings.Split(d, \".\")) < 2 {\n        return fmt.Errorf(\"allowedDataset %q must be project.dataset\", d)\n    }\n}\n// then Initialize","typeGuard":null,"tryCatchPattern":"if _, err := cfg.Initialize(ctx); err != nil {\n    if strings.Contains(err.Error(), \"at least 2 parts\") {\n        // fix allowedDatasets entries to project.dataset and re-init\n    }\n    return err\n}","preventionTips":["Always write allowed datasets as fully-qualified project.dataset strings.","Add config validation for allowedDatasets format before Initialize.","Beware of trailing dots, spaces, or comma-joined values in YAML list entries.","Document the project.dataset requirement in your config templates."],"tags":["go","bigquery","configuration","validation"],"backgroundTag":"invalid-dataset-format","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"}