{"record":{"id":"0c4687da6edbc7c2","repo":"apache/druid","slug":"getposition-is-not-supported-in-kinesis","errorCode":null,"errorMessage":"getPosition() is not supported in Kinesis","messagePattern":"getPosition\\(\\) is not supported in Kinesis","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"extensions-core/kinesis-indexing-service/src/main/java/org/apache/druid/indexing/kinesis/KinesisRecordSupplier.java","lineNumber":643,"sourceCode":"  @Override\n  public void seekToEarliest(Set<StreamPartition<String>> partitions) throws InterruptedException\n  {\n    filterBufferAndResetBackgroundFetch(partitions);\n    partitions.forEach(partition -> partitionSeek(partition, null, ShardIteratorType.TRIM_HORIZON));\n  }\n\n  @Override\n  public void seekToLatest(Set<StreamPartition<String>> partitions) throws InterruptedException\n  {\n    filterBufferAndResetBackgroundFetch(partitions);\n    partitions.forEach(partition -> partitionSeek(partition, null, ShardIteratorType.LATEST));\n  }\n\n  @Nullable\n  @Override\n  public String getPosition(StreamPartition<String> partition)\n  {\n    throw new UnsupportedOperationException(\"getPosition() is not supported in Kinesis\");\n  }\n\n  @Nonnull\n  @Override\n  public List<OrderedPartitionableRecord<String, String, KinesisRecordEntity>> poll(long timeout)\n  {\n    start();\n\n    try {\n      List<MemoryBoundLinkedBlockingQueue.ObjectContainer<OrderedPartitionableRecord<String, String, KinesisRecordEntity>>> polledRecords = new ArrayList<>();\n\n      records.drain(\n          polledRecords,\n          maxBytesPerPoll,\n          timeout,\n          TimeUnit.MILLISECONDS\n      );\n","sourceCodeStart":625,"sourceCodeEnd":661,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-core/kinesis-indexing-service/src/main/java/org/apache/druid/indexing/kinesis/KinesisRecordSupplier.java#L625-L661","documentation":"KinesisRecordSupplier does not implement getPosition; Kinesis partitions are tracked by sequence numbers, and the supplier exposes them via other APIs (getSequenceNumber, getPartitionTimeLag). Calling getPosition throws UnsupportedOperationException by design.","triggerScenarios":"Direct invocation of getPosition(StreamPartition) on a KinesisRecordSupplier — typically generic code written for Kafka suppliers that assumes getPosition exists for all record suppliers.","commonSituations":"Framework/plugin code written against Kafka's KafkaRecordSupplier reused with Kinesis; custom metadata-storage or monitoring code reading current partition position; copy-pasted supplier-agnostic utilities.","solutions":["Replace the getPosition call with getSequenceNumber(partition) which returns the current Kinesis sequence number","Gate generic supplier code on supplier type before calling getPosition","Use getPartitionTimeLag or partition offsets in the datasource metadata table instead"],"exampleFix":"// before\nString pos = supplier.getPosition(partition);\n// after\nString seqNum = supplier.getSequenceNumber(partition);","handlingStrategy":"type-guard","validationCode":"if (supplier instanceof KinesisRecordSupplier) {\n  throw new UnsupportedOperationException(\"use getSequenceNumber instead of getPosition for Kinesis\");\n}","typeGuard":"static boolean supportsGetPosition(RecordSupplier<?, ?, ?> supplier) {\n  return !(supplier instanceof KinesisRecordSupplier);\n}","tryCatchPattern":"try {\n  position = supplier.getPosition(partition);\n} catch (UnsupportedOperationException e) {\n  position = supplier.getSequenceNumber(partition); // Kinesis fallback\n}","preventionTips":["Never call getPosition on Kinesis suppliers; use getSequenceNumber or getPartitionTimeLag","Guard generic supplier-agnostic code by supplier type before position-based APIs","Read the KinesisRecordSupplier Javadoc — position semantics differ from Kafka","Add unit tests covering all supplier implementations you plug into generic utilities"],"tags":["kinesis","unsupported-operation","api-misuse"],"backgroundTag":"unsupported-operation","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}