Question about pv1: num_of_api_keys

Hi

I was stuck in stage 5 and found Question about Handle APIVersions requests stage helpful in solving my issue.

The only thing that I don’t understand is related to the num_of_api_keys. The correct value according to the tests is 2.

In the discussion, it was said that the API_KEYS is a COMPACT_ARRAY (or at least that’s what I understood), and we need to set that field to N+1

The documentation is also saying that this field is an UNSIGNED_VARINT
image

According to this post Making all your integers positive with zigzag encoding 1 is mapped to 2 after applying zigzag encoding. (or zigzag is applied only in case of the signed numbers?? in that case why did kafka documentation mention it?)

is APY_KEYS an ARRAY or a COMPACT_ARRAY? how can we distinguish between the two, as both are referred with the same syntax in the documentation (as [T])

Hi @abdellani, UNSIGNED VARINT does not use zig-zag encoding; only SIGNED VARINT does. The difference in length is solely due to how COMPACT_ARRAY specifies it, namely N+1.

As for your second question, brace yourself:

APY_KEYS can be either COMPACT_ARRAY or ARRAY depending on the scenario and response version.

  • API_KEYS is COMPACT_ARRAY in success scenarios, when the response is v3+.
  • API_KEYS is ARRAY in error scenarios, when the response reverts to v0.
1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.