Handle APIVersions requests #pv1 - format

Edit: (Never mind think the length are varint + 1 so it seems correct)

I noticed some of the solutions people have submitted have the following format for the response:

size - INT32
correlationId - INT32
errcode - INT16

arraySzie - INT8
apiKey - INT16
minVersion - INT16
etc …

This seems wrong, but all those solutions are accepted.

The standard for an array says:

First, the length N is given as an INT32 … A null array is represented with a length of -1.

Also, they set the size to 2 but then only send 1 element in the array.

Here is what I have but it is failing

    buffer.appendInt(0) // initially 0 length
    buffer.appendInt(correlationId) // response header
    buffer.appendShort(errorCode.value)

    buffer.appendInt(1) // Size of the "array" that follows
    buffer.appendShort(RequestApiKey.APIVersions.value) // api key
    buffer.appendShort(3) // min version
    buffer.appendShort(4) // max version
    buffer.appendByte(0) // _tagged_fields
    buffer.appendInt(0) // throttleTimeMs
    buffer.appendByte(0) // _tagged_fields

    val size = buffer.length()
    buffer.setInt(0, size - Int.SIZE_BYTES)
1 Like