{"record":{"id":"aadf3601d3ca934f","repo":"apache/beam","slug":"failed-to-list-first-page-of-fhir-resources-from-s-s","errorCode":null,"errorMessage":"Failed to list first page of FHIR resources from %s: %s","messagePattern":"Failed to list first page of FHIR resources from (.+?): (.+?)","errorType":"exception","errorClass":"NoSuchElementException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java","lineNumber":976,"sourceCode":"    public static FhirResourcePagesIterator ofPatientEverything(\n        HealthcareApiClient client, String resourceName, @Nullable Map<String, Object> parameters) {\n      return new FhirResourcePagesIterator(\n          FhirMethod.PATIENT_EVERYTHING, client, \"\", \"\", resourceName, parameters);\n    }\n\n    @Override\n    public boolean hasNext() throws NoSuchElementException {\n      if (!isFirstRequest) {\n        return this.pageToken != null && !this.pageToken.isEmpty();\n      }\n      try {\n        HttpBody response = executeFhirRequest();\n        JsonObject jsonResponse =\n            JsonParser.parseString(mapper.writeValueAsString(response)).getAsJsonObject();\n        JsonArray resources = jsonResponse.getAsJsonArray(\"entry\");\n        return resources != null && resources.size() != 0;\n      } catch (IOException e) {\n        throw new NoSuchElementException(\n            String.format(\n                \"Failed to list first page of FHIR resources from %s: %s\",\n                fhirStore, e.getMessage()));\n      }\n    }\n\n    @Override\n    public JsonArray next() throws NoSuchElementException {\n      try {\n        HttpBody response = executeFhirRequest();\n        this.isFirstRequest = false;\n        JsonObject jsonResponse =\n            JsonParser.parseString(mapper.writeValueAsString(response)).getAsJsonObject();\n        JsonArray links = jsonResponse.getAsJsonArray(\"link\");\n        this.pageToken = parsePageToken(links);\n        JsonArray resources = jsonResponse.getAsJsonArray(\"entry\");\n        return resources;\n      } catch (IOException e) {","sourceCodeStart":958,"sourceCodeEnd":994,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java#L958-L994","documentation":"The FHIR store 'has any resources' check in HttpHealthcareApiClient throws NoSuchElementException when the initial FHIR search request throws IOException, converting an I/O/API failure into an empty-result signal for the hasNext() contract. The real cause (store not found, no permission, malformed request) is appended in the message.","triggerScenarios":"Calling the method that checks for the first page of FHIR resources (used by FhirIO source hasNext) when the FHIR stores.search/.list REST request fails: wrong fhirStore path, missing healthcare.fhirStoreViewer IAM role, network outage, or API error response.","commonSituations":"Misspelled datasets/{d}/fhirStores/{s} path; service account without FHIR read permissions; transient 5xx during a Beam FHIR import/export pipeline; FHIR store not yet created.","solutions":["Verify the fhirStore full resource path (projects/{p}/locations/{l}/datasets/{d}/fhirStores/{s})","Grant roles/healthcare.fhirStoreViewer to the caller's service account","Check the embedded IOException message for the actual HTTP cause","Confirm the FHIR store exists via `gcloud healthcare fhir-stores describe` and retry on transient failures"],"exampleFix":"// before\nthrow new NoSuchElementException(String.format(\"Failed to list first page of FHIR resources from %s: %s\", fhirStore, e.getMessage()));\n// after\n// validate store accessibility before iterating\ntry {\n  boolean hasResources = client.hasFhirResources(fhirStore);\n} catch (NoSuchElementException e) {\n  throw new IOException(\"Cannot access FHIR store \" + fhirStore + \": \" + e.getMessage(), e);\n}","handlingStrategy":"try-catch","validationCode":"java\nif (!fhirStore.matches(\"projects/[^/]+/locations/[^/]+/datasets/[^/]+/fhirStores/[^/]+\")) {\n  throw new IllegalArgumentException(\"Malformed fhirStore path: \" + fhirStore);\n}","typeGuard":null,"tryCatchPattern":"java\ntry {\n  hasResources = checkFirstPage(fhirStore);\n} catch (NoSuchElementException e) {\n  throw new IOException(\"FHIR store unreachable: \" + e.getMessage(), e);\n}","preventionTips":["Verify the FHIR store exists and IAM read access before running the pipeline","Catch NoSuchElementException and rethrow with the embedded cause for diagnosability","Retry transient failures with backoff","Confirm store region/location matches the client's endpoint"],"tags":["java","google-cloud-healthcare","fhir","io-exception"],"backgroundTag":"http-error-response","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}