apache/beam · warning

Latest message in has null or empty sendTime defaulting to…

Error message

Latest message in {} has null or empty sendTime defaulting to now.

What it means

In getLatestHL7v2SendTime, the newest HL7v2 message returned by the Healthcare API for the given filter has a null or empty sendTime field. The method logs a warning and falls back to using the current instant instead of the message's actual send time. This is not fatal; downstream polling logic will use 'now' as the latest send time.

Solutions

  1. Fix the upstream HL7v2 message ingestion so sendTime (MSH-7) is always populated.
  2. Accept the fallback: verify your pipeline tolerates Instant.now() as the latest send time (may re-read or skip messages).
  3. Adjust the query filter to only match messages with a non-empty sendTime so the null-time message is not selected.
  4. Log/alert on this warning to identify which stores/senders produce time-less messages and re-ingest them.

Example fix

// before: relying on possibly-empty sendTime
String sendTime = response.getHl7V2Messages().get(0).getSendTime();
// after: ensure messages are ingested with sendTime set (MSH-7), or guard client-side
Instant latest = Strings.isNullOrEmpty(sendTime)
    ? Instant.now()
    : Instant.parse(sendTime);
Defensive patterns

Strategy: fallback

Validate before calling

// before invoking, ensure messages carry sendTime by querying the store:
// HL7V2Store filter: "sendTime != "" — or validate MSH-7 presence at ingest time.
if (messages.isEmpty() || Strings.isNullOrEmpty(messages.get(0).getSendTime())) {
  // expect now() fallback; plan windowing accordingly
}

Type guard

boolean hasSendTime(Hl7V2Message m) { return m != null && !Strings.isNullOrEmpty(m.getSendTime()); }

Try / catch

// Not thrown, only warned; add a log alert on 'defaulting to now' to detect affected stores.
// Downstream: treat Instant.now() result as 'unknown' and widen poll windows.

Prevention

When it happens

Trigger: Calling getLatestHL7v2SendTime(hl7v2Store, filter) where the HL7v2 store contains a message whose sendTime metadata is missing or empty (e.g. the message was ingested without a sendTime, or the API returned a Message resource without the field populated).

Common situations: Healthcare HL7v2 ingest pipelines where messages arrive via legacy senders that do not populate MSH-7 (message timestamp); messages imported via bulk import APIs without send time; querying stores with such messages in a WriteToPubSub / HL7v2 polling pipeline.

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/5f134be102546424. 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:349

            .hl7V2Stores()
            .messages()
            .list(hl7v2Store)
            .setFilter(filter)
            .set("view", "full") // needed to retrieve the value for sendTime
            .setOrderBy("sendTime desc")
            // 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 latest 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("Latest message in {} has null or empty sendTime defaulting to now.", hl7v2Store);

      return Instant.now();
    }
    // 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 ListMessagesResponse makeSendTimeBoundHL7v2ListRequest(
      String hl7v2Store,
      Instant start,
      @Nullable Instant end,
      @Nullable String otherFilter,
      @Nullable String orderBy,
      @Nullable String pageToken)
      throws IOException {
    String filter;

View on GitHub (pinned to 12126d8942)