I’m stuck on Stage Include DescribeTopicPartitions in APIVersions (#yk1).
I’ve tried every possible argument but still got the same bytes error.
Can somebody please help me tell me what is wrong with my code it would be a great help, please.
logs:
My code:
def make_response(request: KafkaRequest):
response_header = request.correlation_id.to_bytes(4, byteorder='big')
valid_api_versions = [0, 1, 2, 3, 4]
error_code = (
ErrorCode.NONE
if request.api_version in valid_api_versions
else ErrorCode.UNSUPPORTED_VERSION
)
throttle_time = 0
api_versions = [
(18, 0, 4),
(75 , 0, 0)
]
# Adding tagged fields (b'\x00' for no tagged fields)
tag_buffer = b'\x00'
response_body = (
error_code.value.to_bytes(2, byteorder='big')+
int(2).to_bytes(1, byteorder='big')
)
for api_key, min_ver, max_ver in api_versions:
response_body += (
request.api_key.to_bytes(2, byteorder='big') +
min_ver.to_bytes(2, byteorder='big') +
max_ver.to_bytes(2, byteorder='big')
)
response_body += (
tag_buffer +
throttle_time.to_bytes(4, byteorder='big') +
tag_buffer
)
# Calculate the full message length
message_len = len(response_header) + len(response_body)
# Return the complete response
return message_len.to_bytes(4, byteorder='big') + response_header + response_body