{"record":{"id":"9705a966fd637c1d","repo":"apache/beam","slug":"earliest-message-in-has-null-or-empty-sendtime-defaulting-to","errorCode":null,"errorMessage":"Earliest message in {} has null or empty sendTime defaulting to Epoch.","messagePattern":"Earliest message in (.+?) has null or empty sendTime defaulting to Epoch\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java","lineNumber":314,"sourceCode":"            .hl7V2Stores()\n            .messages()\n            .list(hl7v2Store)\n            .setFilter(filter)\n            .set(\"view\", \"full\") // needed to retrieve the value for sendtime\n            .setOrderBy(\"sendTime\") // default order is ascending\n            // https://cloud.google.com/apis/design/design_patterns#sorting_order\n            .setPageSize(1) // Only interested in the earliest sendTime\n            .execute();\n    if (response.isEmpty()) {\n      throw new IllegalArgumentException(\n          String.format(\n              \"Could not find earliest send time. The filter %s  matched no results on \"\n                  + \"HL7v2 Store: %s\",\n              filter, hl7v2Store));\n    }\n    String sendTime = response.getHl7V2Messages().get(0).getSendTime();\n    if (Strings.isNullOrEmpty(sendTime)) {\n      LOG.warn(\n          \"Earliest message in {} has null or empty sendTime defaulting to Epoch.\", hl7v2Store);\n      return Instant.ofEpochMilli(0);\n    }\n    // sendTime is conveniently RFC3339 UTC \"Zulu\"\n    // https://cloud.google.com/healthcare/docs/reference/rest/v1/projects.locations.datasets.hl7V2Stores.messages#Message\n    return Instant.parse(sendTime);\n  }\n\n  @Override\n  public Instant getLatestHL7v2SendTime(String hl7v2Store, @Nullable String filter)\n      throws IOException {\n    ListMessagesResponse response =\n        client\n            .projects()\n            .locations()\n            .datasets()\n            .hl7V2Stores()\n            .messages()","sourceCodeStart":296,"sourceCodeEnd":332,"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#L296-L332","documentation":"getEarliestHL7v2SendTime queries an HL7v2 store (with a sendTime-ordered filter) to find the earliest message send time, used to compute start offsets. If the earliest message's sendTime field is null or empty, the method logs this warning and falls back to the Unix epoch (Instant.ofEpochMilli(0)) instead of failing — meaning the computed window may start earlier than intended.","triggerScenarios":"Listing HL7v2 messages whose sendTime metadata was never set by the store (older messages, messages ingested via raw create without server-assigned sendTime, or API responses lacking sendTime for the first entry).","commonSituations":"Stores created before sendTime was reliably populated; imports that pre-set explicit sendTime as empty; using getEarliestHL7v2SendTime for Pub/Sub offset calculation on stores with sparse metadata.","solutions":["Accept the fallback if epoch-default semantics are safe for your use case (it only makes the range wider).","Re-ingest or patch affected messages so HL7v2Message.sendTime is populated.","Prefer server-assigned sendTime: create messages without overriding sendTime so the store sets it.","If epoch default is harmful, add a guard in your client code to treat epoch as 'unknown' and handle it explicitly."],"exampleFix":"// before\nInstant earliest = client.getEarliestHL7v2SendTime(store, filter); // may be epoch silently\n// after\nInstant earliest = client.getEarliestHL7v2SendTime(store, filter);\nif (earliest.equals(Instant.ofEpochMilli(0))) {\n  LOG.warn(\"sendTime unavailable for {}; handling unknown-start case\", store);\n}","handlingStrategy":"type-guard","validationCode":"// Java: detect the epoch fallback at the call site\nInstant earliest = client.getEarliestHL7v2SendTime(store, filter);\nboolean unknownSendTime = Instant.ofEpochMilli(0).equals(earliest);","typeGuard":"// Java: narrow to a 'known' send time\njava.util.Optional<Instant> knownSendTime(Instant t) {\n  return Instant.ofEpochMilli(0).equals(t) ? java.util.Optional.empty() : java.util.Optional.of(t);\n}","tryCatchPattern":null,"preventionTips":["Let the Healthcare API assign sendTime (don't override with empty values on create).","Treat epoch results as 'unknown' and widen downstream windows accordingly.","Patch legacy messages missing sendTime metadata."],"tags":["gcp-healthcare","hl7v2","timestamp","fallback"],"backgroundTag":"empty-required-field","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"}