{"record":{"id":"d411e88c16f3b422","repo":"googleapis/mcp-toolbox","slug":"all-resources-must-belong-to-the-same-location-pl","errorCode":null,"errorMessage":"all resources must belong to the same location. Please make separate calls for each distinct location","messagePattern":"all resources must belong to the same location\\. Please make separate calls for each distinct location","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/tools/dataplex/dataplexlookupcontext/dataplexlookupcontext.go","lineNumber":140,"sourceCode":"\t\terr := fmt.Errorf(\"resources cannot be empty\")\n\t\treturn nil, util.NewAgentError(err.Error(), err)\n\t}\n\tvar name string\n\tvar firstLocation string\n\tfor i, resource := range resources {\n\t\tparts := strings.Split(resource, \"/\")\n\t\tif len(parts) < 4 || parts[0] != \"projects\" || parts[2] != \"locations\" {\n\t\t\terr := fmt.Errorf(\"invalid resource format at index %d, must be in the format of projects/{project_id_or_number}/locations/{location}/entryGroups/{group}/entries/{entry}\", i)\n\t\t\treturn nil, util.NewAgentError(err.Error(), err)\n\t\t}\n\n\t\tlocation := parts[3]\n\t\tif i == 0 {\n\t\t\tfirstLocation = location\n\t\t\tproject := source.ProjectID()\n\t\t\tname = fmt.Sprintf(\"projects/%s/locations/%s\", project, location)\n\t\t} else if location != firstLocation {\n\t\t\terr := fmt.Errorf(\"all resources must belong to the same location. Please make separate calls for each distinct location\")\n\t\t\treturn nil, util.NewAgentError(err.Error(), err)\n\t\t}\n\t}\n\n\tresp, err := source.LookupContext(ctx, name, resources)\n\tif err != nil {\n\t\treturn nil, util.ProcessGcpError(err)\n\t}\n\treturn resp, nil\n}\n","sourceCodeStart":122,"sourceCodeEnd":151,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/tools/dataplex/dataplexlookupcontext/dataplexlookupcontext.go#L122-L151","documentation":"dataplex-lookup-context resolves all resources in one Dataplex API call, so every resource must share the same location. Invoke takes the location of the first resource and fails if any subsequent resource's location segment differs, instructing the caller to split the request per location.","triggerScenarios":"resources array contains entries from two or more GCP locations (e.g. one in us-central1 and another in eu-west1).","commonSituations":"An agent batches lookup requests across regions to save calls; search results spanning multiple locations are passed through unfiltered.","solutions":["Group resources by location and issue one dataplex-lookup-context call per location","Filter the input resources to a single location before invoking","Use location from prior search results to bucket the entries client-side"],"exampleFix":"// before\n{\"resources\": [\"projects/p/locations/us-central1/entryGroups/g/entries/e1\", \"projects/p/locations/eu/entryGroups/g/entries/e2\"]}\n// after\n{\"resources\": [\"projects/p/locations/us-central1/entryGroups/g/entries/e1\"]} // separate call for eu","handlingStrategy":"validation","validationCode":"func locationOf(r string) string {\n\tparts := strings.Split(r, \"/\")\n\tif len(parts) >= 4 && parts[0] == \"projects\" && parts[2] == \"locations\" {\n\t\treturn parts[3]\n\t}\n\treturn \"\"\n}\nlocs := map[string]bool{}\nfor _, r := range resources {\n\tlocs[locationOf(r)] = true\n}\nif len(locs) > 1 {\n\treturn fmt.Errorf(\"split resources by location before calling lookup-context\")\n}","typeGuard":null,"tryCatchPattern":"_, terr := tool.Invoke(ctx, src, params, token)\nif terr != nil && strings.Contains(terr.Error(), \"same location\") {\n\t// regroup resources per location and issue one call per group\n}","preventionTips":["Group resources by location before batch lookups","Never mix regions/locations in a single lookup-context call","Persist the location alongside search results for later lookups"],"tags":["go","dataplex","validation","multi-location"],"backgroundTag":"cross-location-resource-batch","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"}