{"record":{"id":"dedbd971ec8d9ca6","repo":"googleapis/mcp-toolbox","slug":"status-d-s-s","errorCode":null,"errorMessage":"status %d %s: %s","messagePattern":"status (.+?) (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/cloudhealthcare/cloud_healthcare.go","lineNumber":282,"sourceCode":"func (s *Source) IsDICOMStoreAllowed(storeID string) bool {\n\tif len(s.allowedDICOMStores) == 0 {\n\t\treturn true\n\t}\n\t_, ok := s.allowedDICOMStores[storeID]\n\treturn ok\n}\n\nfunc (s *Source) UseClientAuthorization() bool {\n\treturn s.UseClientOAuth\n}\n\nfunc parseResults(resp *http.Response) (any, error) {\n\trespBytes, err := io.ReadAll(resp.Body)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"could not read response: %w\", err)\n\t}\n\tif resp.StatusCode > 299 {\n\t\treturn nil, fmt.Errorf(\"status %d %s: %s\", resp.StatusCode, resp.Status, respBytes)\n\t}\n\tvar jsonMap map[string]interface{}\n\tif err := json.Unmarshal(respBytes, &jsonMap); err != nil {\n\t\treturn nil, fmt.Errorf(\"could not unmarshal response as json: %w\", err)\n\t}\n\treturn jsonMap, nil\n}\n\nfunc (s *Source) getService(tokenStr string) (*healthcare.Service, error) {\n\tsvc := s.Service()\n\tvar err error\n\t// Initialize new service if using user OAuth token\n\tif s.UseClientAuthorization() {\n\t\tsvc, err = s.ServiceCreator()(tokenStr)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error creating service from OAuth access token: %w\", err)\n\t\t}\n\t}","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/cloudhealthcare/cloud_healthcare.go#L264-L300","documentation":"parseResults wraps every non-2xx HTTP response from the Cloud Healthcare API into a single error carrying the numeric status code, the textual status (e.g. \"404 Not Found\"), and the raw response body. This library method throws it because FHIR/DICOM requests can fail server-side for many reasons and the raw body usually contains Google's JSON error detail (error.code, error.message, error.status). The message is the generic catch-all for any failed HTTP call made through this source.","triggerScenarios":"Any Cloud Healthcare REST call routed through parseResults (FHIRFetchPage, FHIRPatientEverything, FHIRPatientSearch, GetFHIRResource) when resp.StatusCode > 299: invalid resource IDs, wrong dataset/store names, insufficient IAM permissions (403), missing resources (404), malformed FHIR queries (400), or quota/rate limiting (429).","commonSituations":"Typos in project/location/dataset/FHIR store configuration; a service account lacking roles/healthcare.viewer or healthcare.fhirResourceViewer; querying a FHIR store where the resource type or patient ID does not exist; passing an invalid search parameter that Google rejects with 400.","solutions":["Inspect the response body embedded in the error message — Google returns a JSON {\"error\":{\"code\":...,\"message\":...,\"status\":...}} explaining the real cause","Verify the dataset, FHIR store, project and location names used in the tool parameters exactly match the Cloud Healthcare resource","Check IAM: the caller's identity needs roles/healthcare.viewer (or fhirResourceViewer) on the store/dataset","For 429s, retry with exponential backoff; for 401/403 re-check credential expiry and scopes","Confirm the FHIR store's API version (v1/v1beta1) matches the URL path segment being requested"],"exampleFix":"// before: opaque failure\ntool.Invoke(...) // -> status 404 Not Found: {\"error\":{\"message\":\"FHIR store not found\"}}\n// after: validate store/config existence first\nif _, err := healthcareClient.Projects.Locations.Datasets.FhirStores.Get(storeName).Do(); err != nil {\n    return fmt.Errorf(\"FHIR store %s does not exist or is not accessible: %w\", storeName, err)\n}","handlingStrategy":"try-catch","validationCode":"const isGoogleErr = (body) => { try { const j = JSON.parse(body); return j && j.error && typeof j.error.code === 'number'; } catch { return false; } }","typeGuard":"function isGoogleAPIError(e) { return e instanceof Error && /status \\d{3} /.test(e.message) && e.message.includes('{\"error\"'); }","tryCatchPattern":"try {\n  const result = await tool.invoke({ patientId });\n} catch (e) {\n  const m = /status (\\d{3}) ([^:]+): ([\\s\\S]+)/.exec(e.message);\n  if (m) {\n    const [, code, status, body] = m;\n    let detail; try { detail = JSON.parse(body).error.message; } catch { detail = body; }\n    if (code === '429') { /* retry with backoff */ }\n    else if (code === '403') { /* fix IAM */ }\n    throw new Error(`Healthcare API ${code}: ${detail}`);\n  }\n  throw e;\n}","preventionTips":["Validate FHIR store, dataset, project and location parameters against the actual Google resource hierarchy before invoking","Grant the caller identity roles/healthcare.viewer or finer-grained FHIR roles in IAM","Implement exponential backoff for 429/5xx responses","Log the embedded response body — it contains Google's canonical error.status for programmatic branching"],"tags":["http","google-cloud","healthcare-api","api-error"],"backgroundTag":"http-non-2xx-response","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"}