This is an automated email from the ASF dual-hosted git repository. hgruszecki pushed a commit to branch refactor-binary-7-http in repository https://gitbox.apache.org/repos/asf/iggy.git
commit 0ee9523ad566fcf7082c4c66cba386ad2f55bc95 Author: Hubert Gruszecki <[email protected]> AuthorDate: Fri Mar 27 13:08:03 2026 +0100 fix(server): restore partition count validation in binary handlers The partition count limit (max 1000 per request) was accidentally dropped when command structs were replaced with wire types. The old CreateTopic/CreatePartitions command structs validated this in their Validatable impl, but the new binary handlers received the decoded wire request without checking. Adds MAX_PARTITIONS_PER_REQUEST constant to binary_protocol and validates in both create_topic and create_partitions handlers before forwarding to the control plane. --- core/binary_protocol/src/lib.rs | 3 +++ .../src/binary/handlers/partitions/create_partitions_handler.rs | 5 +++++ core/server/src/binary/handlers/topics/create_topic_handler.rs | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/core/binary_protocol/src/lib.rs b/core/binary_protocol/src/lib.rs index cce1e5d56..9ad698f88 100644 --- a/core/binary_protocol/src/lib.rs +++ b/core/binary_protocol/src/lib.rs @@ -85,3 +85,6 @@ pub use primitives::permissions::{ WireGlobalPermissions, WirePermissions, WireStreamPermissions, WireTopicPermissions, }; pub use primitives::polling_strategy::WirePollingStrategy; + +/// Maximum number of partitions allowed in a single create/delete request. +pub const MAX_PARTITIONS_PER_REQUEST: u32 = 1000; diff --git a/core/server/src/binary/handlers/partitions/create_partitions_handler.rs b/core/server/src/binary/handlers/partitions/create_partitions_handler.rs index e6f37151d..a3548460a 100644 --- a/core/server/src/binary/handlers/partitions/create_partitions_handler.rs +++ b/core/server/src/binary/handlers/partitions/create_partitions_handler.rs @@ -21,6 +21,7 @@ use crate::shard::IggyShard; use crate::shard::transmission::frame::ShardResponse; use crate::shard::transmission::message::{ShardRequest, ShardRequestPayload}; use crate::streaming::session::Session; +use iggy_binary_protocol::MAX_PARTITIONS_PER_REQUEST; use iggy_binary_protocol::requests::partitions::CreatePartitionsRequest; use iggy_common::{IggyError, SenderKind}; use std::rc::Rc; @@ -39,6 +40,10 @@ pub async fn handle_create_partitions( ); shard.ensure_authenticated(session)?; + if !(1..=MAX_PARTITIONS_PER_REQUEST).contains(&req.partitions_count) { + return Err(IggyError::TooManyPartitions); + } + let request = ShardRequest::control_plane(ShardRequestPayload::CreatePartitionsRequest { user_id: session.get_user_id(), command: req, diff --git a/core/server/src/binary/handlers/topics/create_topic_handler.rs b/core/server/src/binary/handlers/topics/create_topic_handler.rs index 78bd60058..eb5da9757 100644 --- a/core/server/src/binary/handlers/topics/create_topic_handler.rs +++ b/core/server/src/binary/handlers/topics/create_topic_handler.rs @@ -22,6 +22,7 @@ use crate::shard::transmission::frame::ShardResponse; use crate::shard::transmission::message::{ShardRequest, ShardRequestPayload}; use crate::streaming::session::Session; use bytes::BytesMut; +use iggy_binary_protocol::MAX_PARTITIONS_PER_REQUEST; use iggy_binary_protocol::WireName; use iggy_binary_protocol::codec::WireEncode; use iggy_binary_protocol::requests::topics::CreateTopicRequest; @@ -45,6 +46,10 @@ pub async fn handle_create_topic( ); shard.ensure_authenticated(session)?; + if req.partitions_count > MAX_PARTITIONS_PER_REQUEST { + return Err(IggyError::TooManyPartitions); + } + let request = ShardRequest::control_plane(ShardRequestPayload::CreateTopicRequest { user_id: session.get_user_id(), command: req,
