apache/beam · error · RuntimeException
There are no messages has a timestamp that is greater than…
Error message
There are no messages has a timestamp that is greater than or equals to the target time or the message format version in this partition is before 0.10.0, topicPartition is:
What it means
Thrown by KafkaIO's ConsumerSpEL.offsetForTime() when consumer.offsetsForTimes() returns no OffsetAndTimestamp for the requested partition. This happens when the partition contains no message at or after the target time, or when Kafka cannot translate timestamps to offsets because the partition's message format version is older than 0.10.0 (timestamps were introduced in 0.10).
Solutions
- Choose a startReadTime within the topic's actual time range (e.g. earliest available timestamp).
- Verify the broker/topic message.format.version is >= 0.10 so timestamps are recorded.
- Check the topicPartition is correct and actually contains messages.
- If nulls are acceptable for the use case, call consumer.offsetsForTimes() directly and handle null instead of using this helper.
- Catch RuntimeException and fall back to earliest/latest offset.
Example fix
// before
builder.setStartReadTime(Instant.parse("2020-01-01T00:00:00Z")); // before any data
// after
Instant start = Instant.now().minus(Duration.ofHours(1)); // within topic retention
builder.setStartReadTime(start); Defensive patterns
Strategy: validation
Validate before calling
Map<TopicPartition, OffsetAndTimestamp> r = consumer.offsetsForTimes(Map.of(tp, millis));
if (r.get(tp) == null) throw new IllegalStateException("No offsets for time " + millis + " on " + tp); Try / catch
try { return ConsumerSpEL.offsetForTime(consumer, tp, ts); } catch (RuntimeException e) { return consumer beginningOffsets...; } Prevention
- Validate message format version >= 0.10
- Choose timestamps inside retention
When it happens
Trigger: Calling ConsumerSpEL.offsetForTime(consumer, topicPartition, time) when: (1) all messages in the partition are older than the requested Instant; (2) the partition's log.message.format.version is below 0.10 so no timestamps exist; (3) offsetsForTimes returns a null value for that partition.
Common situations: Using startReadTime / setStartReadTime with a time beyond the end of the topic; reading old topics written by pre-0.10 Kafka producers; broker-side message format downgrade; typo in the requested timestamp (e.g. future epoch millis).
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- : closing producer after unrecoverable error. The work…
- : consumer thread is interrupted
- consumerPollingTimeout should be > 0.
- Couldn't infer Coder from
- Error while parsing the element
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/da3cf485a08025a7.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/io/kafka/src/main/java/org/apache/beam/sdk/io/kafka/ConsumerSpEL.java:160
}
/**
* Look up the offset for the given partition by timestamp. Throws RuntimeException if there are
* no messages later than timestamp or if this partition does not support timestamp based offset.
*/
@SuppressWarnings("unchecked")
public static long offsetForTime(
Consumer<?, ?> consumer, TopicPartition topicPartition, Instant time) {
checkArgument(hasOffsetsForTimes, "This Kafka Client must support Consumer.OffsetsForTimes().");
// 'value' in the map returned by offsetFoTime() is null if there is no offset for the time.
OffsetAndTimestamp offsetAndTimestamp =
Iterables.getOnlyElement(
consumer.offsetsForTimes(ImmutableMap.of(topicPartition, time.getMillis())).values());
if (offsetAndTimestamp == null) {
throw new RuntimeException(
"There are no messages has a timestamp that is greater than or "
+ "equals to the target time or the message format version in this partition is "
+ "before 0.10.0, topicPartition is: "
+ topicPartition);
} else {
return offsetAndTimestamp.offset();
}
}
}
View on GitHub (pinned to 12126d8942)