Skip to content

Commit 36e6a4b

Browse files
authored
Merge pull request #896 from BrentWheeldon/BrentWheeldon/group-sync-failure-responses
Handle SyncGroup responses with a non-zero error and no assignments
2 parents 733a47d + d9cb8d1 commit 36e6a4b

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Changes and additions to the library will be listed here.
77
- Fix `Kafka::TransactionManager#send_offsets_to_txn` (#866).
88
- Add support for `murmur2` based partitioning.
99
- Add `resolve_seed_brokers` option to support seed brokers' hostname with multiple addresses (#877).
10+
- Handle SyncGroup responses with a non-zero error and no assignments (#896).
1011

1112
## 1.3.0
1213

lib/kafka/protocol/sync_group_response.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ def initialize(error_code:, member_assignment:)
1313
end
1414

1515
def self.decode(decoder)
16+
error_code = decoder.int16
17+
member_assignment_bytes = decoder.bytes
18+
1619
new(
17-
error_code: decoder.int16,
18-
member_assignment: MemberAssignment.decode(Decoder.from_string(decoder.bytes)),
20+
error_code: error_code,
21+
member_assignment: member_assignment_bytes ? MemberAssignment.decode(Decoder.from_string(member_assignment_bytes)) : nil
1922
)
2023
end
2124
end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# frozen_string_literal: true
2+
3+
describe Kafka::Protocol::SyncGroupResponse do
4+
describe ".decode" do
5+
subject(:response) { Kafka::Protocol::SyncGroupResponse.decode(decoder) }
6+
7+
let(:decoder) { Kafka::Protocol::Decoder.new(buffer) }
8+
let(:buffer) { StringIO.new(response_bytes) }
9+
10+
context "the response is successful" do
11+
let(:response_bytes) { "\x00\x00\x00\x00\x007\x00\x00\x00\x00\x00\x01\x00\x1Fsome-topic-f064d6897583eb395896\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x01\xFF\xFF\xFF\xFF" }
12+
13+
it "decodes the response including the member assignment" do
14+
expect(response.error_code).to eq 0
15+
expect(response.member_assignment.topics).to eq({ "some-topic-f064d6897583eb395896" => [0, 1] })
16+
end
17+
end
18+
19+
context "the response is not successful" do
20+
let(:response_bytes) { "\x00\x19\xFF\xFF\xFF\xFF" }
21+
22+
it "decodes the response including the member assignment" do
23+
expect(response.error_code).to eq 25
24+
expect(response.member_assignment).to be_nil
25+
end
26+
end
27+
end
28+
end

0 commit comments

Comments
 (0)