t8y2/dbx · warning · IllegalArgumentException
Peek message count must be between 1 and " + MAX_PEEK_MESSAG
Error message
Peek message count must be between 1 and " + MAX_PEEK_MESSAGE_COUNT
What it means
KafkaAgent.validatePeekCount enforces that the `count` parameter of a peek operation is between 1 and MAX_PEEK_MESSAGE_COUNT. The library throws this IllegalArgumentException before creating a consumer to fail fast on out-of-range peek sizes. It protects the driver from building enormous fetch requests or returning unbounded result sets.
Source
Thrown at agents/drivers/kafka/src/main/java/com/dbx/agent/kafka/KafkaAgent.java:1708
);
}
List<Map<String, Object>> messages = sortAndLimitPeekedMessages(
collection.messages, count, startPosition
);
return peekMessagesResult(messages, collection.incomplete);
}
}
static Map<String, Object> peekMessagesResult(List<Map<String, Object>> messages, boolean incomplete) {
Map<String, Object> result = new LinkedHashMap<>();
result.put("messages", messages);
result.put("incomplete", incomplete);
return result;
}
static int validatedPeekCount(int count) {
if (count < 1 || count > MAX_PEEK_MESSAGE_COUNT) {
throw new IllegalArgumentException(
"Peek message count must be between 1 and " + MAX_PEEK_MESSAGE_COUNT
);
}
return count;
}
static int peekRequestTimeoutMs(JsonObject conn, Properties props) {
Integer connectionTimeout = integerOrNull(conn, "request_timeout_ms");
if (connectionTimeout != null) {
return positiveTimeoutMs("request_timeout_ms", connectionTimeout);
}
String configuredTimeout = props.getProperty(
ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG,
String.valueOf(DEFAULT_REQUEST_TIMEOUT_MS)
);
try {
return positiveTimeoutMs(ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG, Integer.parseInt(configuredTimeout));
} catch (NumberFormatException error) {View on GitHub (pinned to c0390bff16)
Solutions
- Clamp the requested count into the range [1, MAX_PEEK_MESSAGE_COUNT] before calling the peek API.
- Default to a small sane value (e.g. 10) when the caller supplies 0/null.
- Catch IllegalArgumentException and surface a validation message to the user prompting a value in range.
Example fix
// before agent.peek(conn, topic, count /* count = 0 */); // after int safeCount = Math.max(1, Math.min(count, MAX_PEEK_MESSAGE_COUNT)); agent.peek(conn, topic, safeCount);
Defensive patterns
Strategy: validation
Validate before calling
int MAX_PEEK_MESSAGE_COUNT = 100; // match driver constant
if (count < 1 || count > MAX_PEEK_MESSAGE_COUNT) {
throw new IllegalArgumentException("count must be in [1, " + MAX_PEEK_MESSAGE_COUNT + "]");
} Type guard
boolean isValidPeekCount(int count) { return count >= 1 && count <= 100; } Try / catch
try {
result = agent.peek(conn, topic, count);
} catch (IllegalArgumentException e) {
if (e.getMessage().startsWith("Peek message count")) {
result = agent.peek(conn, topic, 10); // safe default
} else throw e;
} Prevention
- Clamp user-supplied page sizes to [1, MAX_PEEK_MESSAGE_COUNT] at the UI/API boundary
- Default null/0 counts to a small sane value before calling peek
- Share the driver's MAX_PEEK_MESSAGE_COUNT constant in client validation
When it happens
Trigger: Calling the Kafka peek API with count < 1 (e.g. 0 or negative) or count > MAX_PEEK_MESSAGE_COUNT. validatedPeekCount is invoked on every peek request that specifies a message count.
Common situations: Defaulting a UI page size to 0 before the user picks a value; passing a raw user input string parsed to 0; copying a 'limit' of 0 from another connector; requesting tens of thousands of messages to 'drain' a topic.
Related errors
- offsets must be an array
- ${name} must be a positive integer
- Kafka partition ${partition} does not exist for topic '${top
- Unsupported peek startPosition: ${value}
- partition must be non-negative
AI-assisted analysis of t8y2/dbx@c0390bff16 (2026-09-05).
Data as JSON: /api/errors/dc273891b8149613.
Report an issue: GitHub.