Kafka Exception InvalidOffsetException
org.apache.kafka.common.errors.InvalidOffsetException
Non-retriable
Consumer
Thrown when the offset for a set of partitions is invalid (either undefined or out of range), and no reset policy has been configured.
Common Causes
- The position for a partition is invalid and cannot be resolved automatically — base type for NoOffsetForPartitionException and OffsetOutOfRangeException
- A seek to an offset that no longer exists, or no committed offset with auto.offset.reset=none
- Stored offsets fell outside the partition's [logStartOffset, logEndOffset] range after retention deleted segments
Solutions
- Decide the reset policy: set auto.offset.reset to earliest or latest, or handle the subclass explicitly with seekToBeginning/seekToEnd
- If you manage offsets externally, validate them against current begin/end offsets before seeking
- Catch the specific subclass (NoOffsetForPartitionException vs OffsetOutOfRangeException) for precise handling
Example Stack Trace
org.apache.kafka.clients.consumer.InvalidOffsetException: ... (see NoOffsetForPartitionException / OffsetOutOfRangeException)Related
Related Consumer exceptions: CommitFailedException · CoordinatorLoadInProgressException · CoordinatorNotAvailableException · FencedInstanceIdException · FencedMemberEpochException · GroupMaxSizeReachedException · IllegalGenerationException · InvalidGroupIdException
Hitting
InvalidOffsetException in production? Conduktor Console gives you real-time visibility into clients, consumer groups, and broker health. Browse every Kafka exception or protocol error code.