apache/beam · info

Earliest message in has null or empty sendTime defaulting…

Error message

Earliest message in {} has null or empty sendTime defaulting to Epoch.

What it means

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.

Solutions

  1. Accept the fallback if epoch-default semantics are safe for your use case (it only makes the range wider).
  2. Re-ingest or patch affected messages so HL7v2Message.sendTime is populated.
  3. Prefer server-assigned sendTime: create messages without overriding sendTime so the store sets it.
  4. If epoch default is harmful, add a guard in your client code to treat epoch as 'unknown' and handle it explicitly.

Example fix

// before
Instant earliest = client.getEarliestHL7v2SendTime(store, filter); // may be epoch silently
// after
Instant earliest = client.getEarliestHL7v2SendTime(store, filter);
if (earliest.equals(Instant.ofEpochMilli(0))) {
  LOG.warn("sendTime unavailable for {}; handling unknown-start case", store);
}
Defensive patterns

Strategy: type-guard

Validate before calling

// Java: detect the epoch fallback at the call site
Instant earliest = client.getEarliestHL7v2SendTime(store, filter);
boolean unknownSendTime = Instant.ofEpochMilli(0).equals(earliest);

Type guard

// Java: narrow to a 'known' send time
java.util.Optional<Instant> knownSendTime(Instant t) {
  return Instant.ofEpochMilli(0).equals(t) ? java.util.Optional.empty() : java.util.Optional.of(t);
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/9705a966fd637c1d. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java:314

            .hl7V2Stores()
            .messages()
            .list(hl7v2Store)
            .setFilter(filter)
            .set("view", "full") // needed to retrieve the value for sendtime
            .setOrderBy("sendTime") // default order is ascending
            // https://cloud.google.com/apis/design/design_patterns#sorting_order
            .setPageSize(1) // Only interested in the earliest sendTime
            .execute();
    if (response.isEmpty()) {
      throw new IllegalArgumentException(
          String.format(
              "Could not find earliest send time. The filter %s  matched no results on "
                  + "HL7v2 Store: %s",
              filter, hl7v2Store));
    }
    String sendTime = response.getHl7V2Messages().get(0).getSendTime();
    if (Strings.isNullOrEmpty(sendTime)) {
      LOG.warn(
          "Earliest message in {} has null or empty sendTime defaulting to Epoch.", hl7v2Store);
      return Instant.ofEpochMilli(0);
    }
    // sendTime is conveniently RFC3339 UTC "Zulu"
    // https://cloud.google.com/healthcare/docs/reference/rest/v1/projects.locations.datasets.hl7V2Stores.messages#Message
    return Instant.parse(sendTime);
  }

  @Override
  public Instant getLatestHL7v2SendTime(String hl7v2Store, @Nullable String filter)
      throws IOException {
    ListMessagesResponse response =
        client
            .projects()
            .locations()
            .datasets()
            .hl7V2Stores()
            .messages()

View on GitHub (pinned to 12126d8942)