From 3940d343e5475b66f9b1f4230b8ceae57c689c03 Mon Sep 17 00:00:00 2001 From: Aleksander Date: Wed, 11 Feb 2026 12:06:45 +0100 Subject: [PATCH] Enforce Kinesis MaxRecords API limit in config builder Add MaxMaxRecords constant and panic if exceeded in WithMaxRecords. Update changelog. --- CHANGELOG.md | 6 ++++++ clientlibrary/config/config.go | 3 +++ clientlibrary/config/kcl-config.go | 3 +++ 3 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cb7947..a4d2c99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.1] - 2026-02-11 + +### Fixed + +- Integer overflow in MaxRecords int to int32 conversion (polling-shard-consumer.go) + ## [0.2.0] - 2026-02-11 ### Added diff --git a/clientlibrary/config/config.go b/clientlibrary/config/config.go index e14559d..7cade9b 100644 --- a/clientlibrary/config/config.go +++ b/clientlibrary/config/config.go @@ -75,6 +75,9 @@ const ( // DefaultMaxRecords Max records to fetch from Kinesis in a single GetRecords call. DefaultMaxRecords = 10000 + // MaxMaxRecords Upper bound for MaxRecords (Kinesis GetRecords API limit). + MaxMaxRecords = 10000 + // DefaultIdleTimeBetweenReadsMillis The default value for how long the {@link ShardConsumer} // should sleep if no records are returned from the call to DefaultIdleTimeBetweenReadsMillis = 1000 diff --git a/clientlibrary/config/kcl-config.go b/clientlibrary/config/kcl-config.go index 17f61ad..6215b9e 100644 --- a/clientlibrary/config/kcl-config.go +++ b/clientlibrary/config/kcl-config.go @@ -164,6 +164,9 @@ func (c *KinesisClientLibConfiguration) WithShardSyncIntervalMillis(shardSyncInt func (c *KinesisClientLibConfiguration) WithMaxRecords(maxRecords int) *KinesisClientLibConfiguration { checkIsValuePositive("MaxRecords", maxRecords) + if maxRecords > MaxMaxRecords { + log.Panicf("MaxRecords must not exceed %d (Kinesis API limit), got: %d", MaxMaxRecords, maxRecords) + } c.MaxRecords = maxRecords return c }