{"record":{"id":"40bdb0b41acd35e1","repo":"googleapis/mcp-toolbox","slug":"invalid-fhir-url-path-structure-path-too-short","errorCode":null,"errorMessage":"invalid FHIR URL path structure: path too short","messagePattern":"invalid FHIR URL path structure: path too short","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/cloudhealthcare/cloud_healthcare.go","lineNumber":351,"sourceCode":"\n\tparsed.Host = strings.ToLower(parsed.Host)\n\thost := parsed.Host\n\tif h, _, err := net.SplitHostPort(host); err == nil {\n\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}","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/cloudhealthcare/cloud_healthcare.go#L333-L369","documentation":"After host checks, the URL path is cleaned and split; a genuine Healthcare API FHIR page URL must have at least 10 slash-separated segments (version, projects, project, locations, location, datasets, dataset, fhirStores, store, fhir/...). This error means the path is structurally too short to be a valid FHIR resource page URL, so the library refuses to follow it.","triggerScenarios":"A short URL like https://healthcare.googleapis.com/v1/projects/p/locations/l/datasets/d/fhirStores/f or a bare search endpoint without the resource segment is passed as a page URL to FHIRFetchPage.","commonSituations":"An LLM reconstructing the next-page URL from memory instead of copying links.next; confusing a FHIR store's base URL with a page URL; passing a non-FHIR (DICOM/HL7v2) store URL into the FHIR pagination path.","solutions":["Copy the full links.next URL from the previous FHIR response verbatim, including query string","Confirm the URL targets a FHIR store path .../datasets/<ds>/fhirStores/<store>/fhir/<Resource> with a pageToken/pageOffset query","Do not truncate the URL at '&'; keep all query parameters","If paginating manually, build the URL with the full 10-segment path"],"exampleFix":"// before (too short)\npage := \"https://healthcare.googleapis.com/v1/projects/p/locations/l/datasets/d/fhirStores/f\"\n// after (full page URL from links.next)\npage := \"https://healthcare.googleapis.com/v1/projects/p/locations/l/datasets/d/fhirStores/f/fhir/Patient?pageToken=CAs\"","handlingStrategy":"validation","validationCode":"function looksLikeFHIRPageURL(u) {\n  const parts = new URL(u).pathname.split('/').filter(Boolean);\n  return parts.length >= 10 && parts[1] === 'projects' && parts[3] === 'locations' && parts[5] === 'datasets' && parts[7] === 'fhirStores';\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy page URLs verbatim from the previous response's links.next; never reconstruct from memory","Verify the URL contains the full .../datasets/<ds>/fhirStores/<store>/fhir/<ResourceType> path before paginating","Keep the full query string including pageToken"],"tags":["url-validation","fhir","pagination","path"],"backgroundTag":"invalid-url-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"}