Skip to content

Commit 86a72ef

Browse files
fix: send null instead of empty string when describing default client quotas (#3128)
DescribeClientQuota currently fails with the following error message logged by the Kafka broker when trying to describe default client quotas: ``` org.apache.kafka.common.errors.InvalidRequestException: Request specified MATCH_TYPE_DEFAULT, but also specified a match string ``` This is because we are currently sending an empty string (`""`) instead of a null as the match string The Java client simply ignores the match string here to avoid this issue, so I propose we do the same https://github.com/apache/kafka/blob/3ed590288fd773902f7791959e8f081ff937c144/clients/src/main/java/org/apache/kafka/common/requests/DescribeClientQuotasRequest.java#L54-L55 --------- Signed-off-by: Peter Dannemann <[email protected]>
1 parent 623d153 commit 86a72ef

3 files changed

+10
-6
lines changed

describe_client_quotas_request.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (d *QuotaFilterComponent) encode(pe packetEncoder) error {
8787
return err
8888
}
8989
} else if d.MatchType == QuotaMatchDefault {
90-
if err := pe.putString(""); err != nil {
90+
if err := pe.putNullableString(nil); err != nil {
9191
return err
9292
}
9393
} else {

describe_client_quotas_request_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ var (
1313
describeClientQuotasRequestDefaultUser = []byte{
1414
0, 0, 0, 1, // components len
1515
0, 4, 'u', 's', 'e', 'r', // entity type
16-
1, // match type (default)
17-
0, 0, // match *string
16+
1, // match type (default)
17+
255, 255, // match *string
1818
0, // strict
1919
}
2020

@@ -32,8 +32,8 @@ var (
3232
2, // match type (any)
3333
255, 255, // match *string
3434
0, 9, 'c', 'l', 'i', 'e', 'n', 't', '-', 'i', 'd', // entity type
35-
1, // match type (default)
36-
0, 0, // match *string
35+
1, // match type (default)
36+
255, 255, // match *string
3737
0, // strict
3838
}
3939
)

functional_admin_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ func TestFuncAdminQuotas(t *testing.T) {
5151
}
5252

5353
// Check that we now have a quota entry
54-
quotas, err = adminClient.DescribeClientQuotas(nil, false)
54+
defaultUserFilter := QuotaFilterComponent{
55+
EntityType: QuotaEntityUser,
56+
MatchType: QuotaMatchDefault,
57+
}
58+
quotas, err = adminClient.DescribeClientQuotas([]QuotaFilterComponent{defaultUserFilter}, false)
5559
if err != nil {
5660
t.Fatal(err)
5761
}

0 commit comments

Comments
 (0)