{"record":{"id":"bd814b0bac525677","repo":"googleapis/mcp-toolbox","slug":"invalid-path-expected-projects-got-q","errorCode":null,"errorMessage":"invalid path: expected 'projects', got %q","messagePattern":"invalid path: expected 'projects', got %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/cloudhealthcare/cloud_healthcare.go","lineNumber":359,"sourceCode":"\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() {\n\t\treturn \"\", fmt.Errorf(\"invalid dataset ID %q: must match source dataset %q\", parts[6], s.DatasetID())\n\t}\n\tif parts[7] != \"fhirStores\" {\n\t\treturn \"\", fmt.Errorf(\"invalid path: expected 'fhirStores', got %q\", parts[7])","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/cloudhealthcare/cloud_healthcare.go#L341-L377","documentation":"The page URL path is validated segment-by-segment against the canonical Healthcare API layout (v1/projects/<project>/locations/<location>/datasets/<ds>/fhirStores/<store>/...). This error means segment[1] is not the literal string \"projects\", so the URL does not follow the required structure and is rejected before any request is made.","triggerScenarios":"A page URL whose second path segment differs from \"projects\" — e.g. a relative path that lost its first segments, a URL with the version segment doubled, or a proxy path prefix like /api/projects/... shifting all segments.","commonSituations":"Reverse proxy base-path prefixes changing segment order; LLM-written URLs with typos (\"project\" singular, \"Projects\" capitalized — comparison is case-sensitive); URL-encoding of the segment.","solutions":["Use the exact links.next URL from the previous Google response — it always has \"projects\" as the second segment","Remove any proxy path prefixes from the page URL or decode %2F-encoded slashes causing misalignment","Fix casing: segments are lowercase and case-sensitive (\"projects\", not \"Projects\")","Count the segments: v1(0)/projects(1)/<project>(2)/locations(3)/..."],"exampleFix":"// before (proxy prefix shifted segments)\npage := \"https://healthcare.googleapis.com/v1/api/projects/p/locations/l/...\"\n// after (canonical Google path)\npage := \"https://healthcare.googleapis.com/v1/projects/p/locations/l/datasets/d/fhirStores/f/fhir/Patient?pageToken=x\"","handlingStrategy":"validation","validationCode":"function hasCanonicalSegments(u) { const p = new URL(u).pathname.split('/').filter(Boolean); return p[0]?.startsWith('v') && p[1] === 'projects' && p[3] === 'locations'; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Strip proxy base-path prefixes from page URLs so segments align with the canonical layout","Use lowercase literal segment names: projects, locations, datasets, fhirStores","Compare against a captured links.next URL when debugging segment mismatches"],"tags":["url-validation","fhir","path","pagination"],"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"}