{"record":{"id":"4456f56ba56ea5ac","repo":"googleapis/mcp-toolbox","slug":"invalid-api-version-prefix-q","errorCode":null,"errorMessage":"invalid API version prefix: %q","messagePattern":"invalid API version prefix: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/cloudhealthcare/cloud_healthcare.go","lineNumber":355,"sourceCode":"\t\thost = h\n\t}\n\tif _, ok := allowedFHIRHosts[host]; !ok {\n\t\treturn \"\", fmt.Errorf(\"URL host must be an allowed FHIR host, got %q\", host)\n\t}\n\n\t// Clean and split path\n\tcleanPath := path.Clean(parsed.Path)\n\t// Truncate leading and trailing slashes for easier splitting\n\ttrimmed := strings.Trim(cleanPath, \"/\")\n\tparts := strings.Split(trimmed, \"/\")\n\n\t// Page URL format Reference: https://docs.cloud.google.com/healthcare-api/docs/how-tos/fhir-search#using_the_search_method_with_get\n\tif len(parts) < 10 {\n\t\treturn \"\", fmt.Errorf(\"invalid FHIR URL path structure: path too short\")\n\t}\n\n\tif !isValidAPIVersion(parts[0]) {\n\t\treturn \"\", fmt.Errorf(\"invalid API version prefix: %q\", parts[0])\n\t}\n\n\tif parts[1] != \"projects\" {\n\t\treturn \"\", fmt.Errorf(\"invalid path: expected 'projects', got %q\", parts[1])\n\t}\n\tif parts[2] != s.Project() {\n\t\treturn \"\", fmt.Errorf(\"invalid project %q: must match source project %q\", parts[2], s.Project())\n\t}\n\tif parts[3] != \"locations\" {\n\t\treturn \"\", fmt.Errorf(\"invalid path: expected 'locations', got %q\", parts[3])\n\t}\n\tif parts[4] != s.Region() {\n\t\treturn \"\", fmt.Errorf(\"invalid location/region %q: must match source region %q\", parts[4], s.Region())\n\t}\n\tif parts[5] != \"datasets\" {\n\t\treturn \"\", fmt.Errorf(\"invalid path: expected 'datasets', got %q\", parts[5])\n\t}\n\tif parts[6] != s.DatasetID() {","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/cloudhealthcare/cloud_healthcare.go#L337-L373","documentation":"The first path segment of a FHIR page URL must be a valid Google Healthcare API version, checked by isValidAPIVersion (starts with 'v' followed by digits, e.g. v1, v1beta1). This error means the URL does not begin with a recognized version segment, so the library cannot trust the URL shape and rejects it.","triggerScenarios":"A page URL whose first path segment is something like \"healthcare\", \"fhir\", a full domain repeated, or \"v\" with no numeric version (isValidAPIVersion requires len>=2 and v[0]=='v' followed by digits) is passed to FHIRFetchPage.","commonSituations":"Passing a generic https://healthcare.googleapis.com/fhir/... URL that skips the version; a proxy-prepended path segment; hand-built URLs that omit /v1/.","solutions":["Ensure the page URL starts with the API version segment, e.g. https://healthcare.googleapis.com/v1/projects/...","Use only v1 (GA) or v1beta1 paths as documented for the FHIR store","Copy links.next verbatim rather than rebuilding the URL","Check the FHIR store's configured version; beta stores use /v1beta1/ paths"],"exampleFix":"// before (missing version)\npage := \"https://healthcare.googleapis.com/projects/p/locations/l/datasets/d/fhirStores/f/fhir/Patient?pageToken=x\"\n// after\npage := \"https://healthcare.googleapis.com/v1/projects/p/locations/l/datasets/d/fhirStores/f/fhir/Patient?pageToken=x\"","handlingStrategy":"validation","validationCode":"function hasAPIVersion(u) { const first = new URL(u).pathname.split('/').filter(Boolean)[0]; return /^v\\d+([a-z]+\\d*)?$/.test(first); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Include the version segment (/v1/ or /v1beta1/) in any manually built FHIR URL","Match the version to the FHIR store's configured API version","Prefer links.next from responses over hand-built URLs"],"tags":["url-validation","api-version","fhir","path"],"backgroundTag":"invalid-api-version","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"}