{"record":{"id":"58e7624459e39dcd","repo":"apache/beam","slug":"error-listing-hl7v2-messages-from-s-s","errorCode":null,"errorMessage":"Error listing HL7v2 Messages from %s: %s","messagePattern":"Error listing HL7v2 Messages 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":889,"sourceCode":"                    hl7v2Store, e.getMessage()));\n          }\n        }\n        return this.pageToken != null;\n      }\n\n      @Override\n      public List<HL7v2Message> next() throws NoSuchElementException {\n        try {\n          ListMessagesResponse response =\n              makeListRequest(client, hl7v2Store, start, end, filter, orderBy, pageToken);\n          this.isFirstRequest = false;\n          this.pageToken = response.getNextPageToken();\n          List<Message> msgs = response.getHl7V2Messages();\n\n          return msgs.stream().map(HL7v2Message::fromModel).collect(Collectors.toList());\n        } catch (IOException e) {\n          this.pageToken = null;\n          throw new NoSuchElementException(\n              String.format(\n                  \"Error listing HL7v2 Messages from %s: %s\", hl7v2Store, e.getMessage()));\n        }\n      }\n    }\n  }\n\n  /** The type FhirResourcePagesIterator for methods which return paged output. */\n  public static class FhirResourcePagesIterator implements Iterator<JsonArray> {\n\n    public enum FhirMethod {\n      SEARCH,\n      PATIENT_EVERYTHING\n    }\n\n    private final FhirMethod fhirMethod;\n    private final String fhirStore;\n    private final String resourceType;","sourceCodeStart":871,"sourceCodeEnd":907,"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#L871-L907","documentation":"HttpHealthcareApiClient's HL7v2 message listing paginator wraps any IOException from the Cloud Healthcare API call in a NoSuchElementException so the Java Stream/Iterator contract can be preserved. The original API error message is embedded in the formatted message, so the root cause (network, permissions, bad store name) is in the trailing %s.","triggerScenarios":"Iterating HL7v2 messages via HL7v2MessagePages.next() when the underlying healthcare.projects.locations.datasets.hl7V2Stores.messages.list call throws IOException: bad hl7v2Store path, missing IAM roles (healthcare.hl7V2StoreViewer), network failure, quota exhaustion, or 4xx/5xx from the API.","commonSituations":"Typo in the projects/{p}/locations/{l}/datasets/{d}/hl7V2Stores/{s} path; service account lacking healthcare.hl7V2Stores.get/messages.list; transient network errors in long-running Beam pipelines; store deleted mid-pipeline.","solutions":["Check the hl7v2Store path string matches projects/{project}/locations/{location}/datasets/{dataset}/hl7V2Stores/{store} exactly","Grant the service account the roles/healthcare.hl7v2StoreViewer (or messages.list) permission","Log/unwrap the embedded IOException message (the text after the second colon) for the real cause","Verify store exists with `gcloud healthcare hl7v2-stores describe` and check network/firewall and retry for transient errors"],"exampleFix":"// before\nthrow new NoSuchElementException(String.format(\"Error listing HL7v2 Messages from %s: %s\", hl7v2Store, e.getMessage()));\n// after\n// catch NoSuchElementException and log getCause/message; validate the store path first\ntry {\n  new HttpHealthcareApiClient().listMessages(hl7v2Store, filter, pageToken);\n} catch (IOException check) {\n  throw new IllegalArgumentException(\"Invalid or inaccessible hl7v2Store: \" + hl7v2Store, check);\n}","handlingStrategy":"try-catch","validationCode":"java\nif (!hl7v2Store.matches(\"projects/[^/]+/locations/[^/]+/datasets/[^/]+/hl7V2Stores/[^/]+\")) {\n  throw new IllegalArgumentException(\"Malformed hl7v2Store path: \" + hl7v2Store);\n}","typeGuard":null,"tryCatchPattern":"java\ntry {\n  iterator.next();\n} catch (NoSuchElementException e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Error listing HL7v2 Messages\")) {\n    throw new IOException(\"HL7v2 listing failed for \" + storePath + \": \" + e.getMessage(), e);\n  }\n  throw e; // genuine end-of-iteration\n}","preventionTips":["Validate the full resource path format before iteration","Pre-flight the store with a describe call and check IAM","Log the embedded IOException cause, not just the wrapper message","Add retry/backoff for transient network errors in pipelines"],"tags":["java","google-cloud-healthcare","io-exception","hl7v2"],"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"}