{"record":{"id":"d32c9d68f13a9804","repo":"apache/beam","slug":"get-request-for-s-returned-null-hl7v2io","errorCode":null,"errorMessage":"GET request for %s returned null","messagePattern":"GET request for (.+?) returned null","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HL7v2IO.java","lineNumber":570,"sourceCode":"\n    private final Counter failedMessageGets =\n        Metrics.counter(HL7v2MessageClient.class, \"failed-message-reads\");\n    private final Counter successfulHL7v2MessageGets =\n        Metrics.counter(HL7v2MessageClient.class, \"successful-hl7v2-message-gets\");\n    private static final Logger LOG = LoggerFactory.getLogger(HL7v2MessageClient.class);\n    private final HealthcareApiClient client;\n\n    /** Instantiates a new HL7v2MessageClient (HCLS API v1). */\n    HL7v2MessageClient(HealthcareApiClient client) {\n      this.client = client;\n    }\n\n    private HL7v2Message fetchMessage(String msgId)\n        throws IOException, ParseException, IllegalArgumentException {\n      try {\n        com.google.api.services.healthcare.v1.model.Message msg = client.getHL7v2Message(msgId);\n        if (msg == null) {\n          throw new IOException(String.format(\"GET request for %s returned null\", msgId));\n        }\n        this.successfulHL7v2MessageGets.inc();\n        return HL7v2Message.fromModel(msg);\n      } catch (Exception e) {\n        failedMessageGets.inc();\n        LOG.warn(\n            \"Error fetching HL7v2 message with ID {} writing to Dead Letter Queue. \", msgId, e);\n        throw e;\n      }\n    }\n  }\n\n  /**\n   * List HL7v2 messages in HL7v2 Stores with optional filter.\n   *\n   * <p>This transform is optimized for splitting of message.list calls for large batches of\n   * historical data and assumes rather continuous stream of sendTimes.\n   *","sourceCodeStart":552,"sourceCodeEnd":588,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HL7v2IO.java#L552-L588","documentation":"HL7v2IO's fetchMessage performs a GET of an HL7v2 message by ID via the Healthcare API client. If the client returns a null Message model (i.e., the API produced no entity), the method wraps this in an IOException with the requested message ID so the failure surfaces through the normal IO error path (it also increments the failedMessageGets counter in the catch block).","triggerScenarios":"fetchMessage(msgId) is called and client.getHL7v2Message(msgId) returns null — the Healthcare API GET request completed without throwing but yielded no message object (message deleted concurrently, bad store path, or empty response body deserialized to null).","commonSituations":"Streaming pipelines reading from an HL7v2 store while messages are being purged/acknowledged by another process; msgId assembled from notification payloads that reference already-deleted messages; misconfigured project/dataset/store path that returns an empty body instead of 404.","solutions":["Verify the message ID / resource name exists in the HL7v2 store (list messages or check the Cloud Console) before fetching.","Retry the fetch — transient API issues can yield an empty response; the surrounding code already retries/DEAD-letters via the catch block.","Check the HL7v2 store path (project/location/dataset/store) used by the IO is correct and the message wasn't deleted by a concurrent consumer.","Handle the IOException in the caller's error-handling PCollection so the pipeline doesn't crash on single missing messages."],"exampleFix":"// before\nString msgId = notification.getMessageName();\nHL7v2Message msg = io.fetchMessage(msgId); // IOException if deleted\n\n// after\ntry {\n  HL7v2Message msg = io.fetchMessage(msgId);\n} catch (IOException e) {\n  LOG.warn(\"HL7v2 message %s no longer available, skipping\", msgId, e);\n}","handlingStrategy":"try-catch","validationCode":"if (msgId == null || !msgId.matches(\"projects/[^/]+/locations/[^/]+/datasets/[^/]+/hl7V2Stores/[^/]+/messages/.+\")) {\n  throw new IllegalArgumentException(\"Invalid HL7v2 message name: \" + msgId);\n}","typeGuard":null,"tryCatchPattern":"try {\n  HL7v2Message msg = fetchMessage(msgId);\n} catch (IOException | ParseException e) {\n  LOG.warn(\"GET for {} returned null/failed: {}\", msgId, e.getMessage());\n  // route to dead-letter or retry\n}","preventionTips":["Don't delete messages concurrently while a pipeline reads them (or tolerate skips).","Validate message resource names extracted from notifications before fetching.","Monitor failedMessageGets counter for rising null-fetch rates."],"tags":["java","google-cloud-healthcare","hl7v2","io","null-response"],"backgroundTag":"entity-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}