diff --git a/src/v/kafka/server/handlers/fetch.cc b/src/v/kafka/server/handlers/fetch.cc index b0c619fa356f..429f115befe3 100644 --- a/src/v/kafka/server/handlers/fetch.cc +++ b/src/v/kafka/server/handlers/fetch.cc @@ -797,7 +797,10 @@ class simple_fetch_planner final : public fetch_planner::impl { .strict_max_bytes = octx.response_size > 0, .skip_read = bytes_left_in_plan == 0 && max_bytes == 0, .read_from_follower = octx.request.has_rack_id(), - .consumer_rack_id = octx.request.data.rack_id, + .consumer_rack_id = octx.request.has_rack_id() + ? std::make_optional( + octx.request.data.rack_id) + : std::nullopt, .abort_source = octx.rctx.abort_source(), .client_address = model::client_address_t{client_address}, };