{"record":{"id":"036c8863080c3d54","repo":"apache/beam","slug":"could-not-find-earliest-send-time-the-filter-s-matched-no","errorCode":null,"errorMessage":"Could not find earliest send time. The filter %s  matched no results on HL7v2 Store: %s","messagePattern":"Could not find earliest send time\\. The filter (.+?)  matched no results on HL7v2 Store: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/healthcare/HttpHealthcareApiClient.java","lineNumber":306,"sourceCode":"  @Override\n  public Instant getEarliestHL7v2SendTime(String hl7v2Store, @Nullable String filter)\n      throws IOException {\n    ListMessagesResponse response =\n        client\n            .projects()\n            .locations()\n            .datasets()\n            .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)","sourceCodeStart":288,"sourceCodeEnd":324,"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#L288-L324","documentation":"HttpHealthcareApiClient.getEarliestHL7v2SendTime queries the HL7v2 store listing messages ordered by sendTime ascending with page size 1 to find the earliest send time. If the filtered listing returns an empty response (no messages matched the filter), it throws IllegalArgumentException because the earliest send time is undefined for an empty result set.","triggerScenarios":"getEarliestHL7v2SendTime(store, filter) is called with a filter that matches zero messages — typically a sendTime window filter that excludes all stored messages (e.g. searching for messages sent after a timestamp when none exist, or a filter on the wrong store).","commonSituations":"Sync/backfill jobs computing a watermark on an empty or newly created HL7v2 store; filters built with start/end times that fall outside all stored messages; pointing at a store other than the one holding the data.","solutions":["Validate the filter's time range covers stored data, or omit/guard the sendTime filter when the store may be empty.","Check the store path is correct and contains messages (list a page first, or catch empty results).","Wrap the call in try-catch for IllegalArgumentException and treat empty stores as 'no earliest send time' (use epoch/now) in your pipeline logic.","Inspect the generated filter string (logging it) to confirm it matches the expected message set."],"exampleFix":"// before\nInstant earliest = Instant.parse(client.getEarliestHL7v2SendTime(store, filter)); // throws on empty\n\n// after\nInstant earliest;\ntry {\n  earliest = Instant.parse(client.getEarliestHL7v2SendTime(store, filter));\n} catch (IllegalArgumentException e) {\n  LOG.warn(\"No messages matched filter on {}\", store);\n  earliest = Instant.EPOCH;\n}","handlingStrategy":"try-catch","validationCode":"// check store non-empty before querying earliest send time\nListMessagesResponse page = client.listMessages(store, null, \"\", 1);\nif (page.isEmpty()) { /* store empty: skip earliest-send-time computation */ }","typeGuard":null,"tryCatchPattern":"try {\n  Instant earliest = Instant.parse(client.getEarliestHL7v2SendTime(store, filter));\n} catch (IllegalArgumentException e) {\n  earliest = Instant.EPOCH; // empty result set\n}","preventionTips":["Guard against empty stores before computing send-time bounds.","Sanity-check filter time ranges against actual data.","Log the filter string so mismatches are diagnosable."],"tags":["java","google-cloud-healthcare","hl7v2","empty-result","illegal-argument"],"backgroundTag":"empty-result-set","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"}