It’s a little confusing here. It says that the first 4 bytes of a request is the length of the field. Then we get into the request header and body. However, in this part, the first 4 bytes are the request_api_key and request_api_version. I see that it states that they length will not e validated but that doesn’t mean that it won’t be passed since that Kafka docs state that it should be passed. I could be missing something but shouldn’t the first 4 bytes be the length, then 5 and 6 be the api key followed by api version and so forth?
I’m new to working with bytes and buffers so I could be wrong but would love some guidance here.
The first 4 bytes are indeed the length, yep. We just won’t “validate” the contents of those 4 bytes in this stage - our tester will just skip those 4 bytes and validate the rest. In later stages once the full response is implemented we’ll perform proper validations.
We do this because at this point the response is incomplete, so it’s hard to assert the length (once you pass later stages, the length will be higher, at this stage it’s expected that the length will be shorter).
While we may not be validating the contents, shouldn’t the length still be sent with the initial request? I should skip the first 4 bytes and then move right into request_api_key.
However, it seems at this phase, the first 4 bytes are request_api_key and request_api_version.
All Kafka “requests” start with 4 bytes, indicating the number of bytes the request is made of.
The first few challenges will not check whether the length you write is correct, but as far as I know, all the requests you receive use the correct length.