#VT6 (Listing Partitions - List for an unknown topic)

            responseBody = append(responseBody, 0)          // tag buffer
			responseBody = append(responseBody, 0, 0, 0, 0) // throttle time

			nReadBytes, topics, err = ParseTopic(messageBuffer[nReadBytes+1:]) // tag buffer
			if err != nil {
				return nil, err
			}

			// topics array with the requested topic (as per CodeCrafters requirements)
			responseBody = append(responseBody, byte(len(topics)+1)) // topics array length

			for _, topicName := range topics {

				// Error code for this topic
				errorCodeBytes := make([]byte, 2)
				binary.BigEndian.PutUint16(errorCodeBytes, uint16(UNKNOWN_TOPIC_OR_PARTITION))
				responseBody = append(responseBody, errorCodeBytes...)

				// Topic name length and name
				topicNameLengthBytes := make([]byte, 2)
				binary.BigEndian.PutUint16(topicNameLengthBytes, uint16(len(topicName)))
				responseBody = append(responseBody, topicNameLengthBytes...)
				responseBody = append(responseBody, []byte(topicName)...) // topic name

				// Topic ID (16 bytes of zeros for unknown topic)
				responseBody = append(responseBody, make([]byte, 16)...) // topic id (16 bytes of zeros)

				// is_internal (false)
				responseBody = append(responseBody, 0x00)

				// Partitions array (empty for unknown topic)
				responseBody = append(responseBody, 0x01) // partitions array length (0 + 1 for compact array)

				// topic_authorized_operations (INT32 - set to -1 for unknown)
				responseBody = append(responseBody, 0xff, 0xff, 0xff, 0xff)

				// tag buffer
				responseBody = append(responseBody, 0)
			}

			// next_cursor (null cursor - no more topics)
			responseBody = append(responseBody, 0xff) // null cursor
			responseBody = append(responseBody, 0)    // tag buffer

[tester::#VT6] Sending “DescribeTopicPartitions” (version: 0) request (Correlation id: 1713048511)
[tester::#VT6] Hexdump of sent “DescribeTopicPartitions” request:
[tester::#VT6] Idx | Hex | ASCII
[tester::#VT6] -----±------------------------------------------------±----------------
[tester::#VT6] 0000 | 00 00 00 31 00 4b 00 00 66 1b 0b bf 00 0c 6b 61 | …1.K..f…ka
[tester::#VT6] 0010 | 66 6b 61 2d 74 65 73 74 65 72 00 02 12 75 6e 6b | fka-tester…unk
[tester::#VT6] 0020 | 6e 6f 77 6e 2d 74 6f 70 69 63 2d 73 61 7a 00 00 | nown-topic-saz..
[tester::#VT6] 0030 | 00 00 01 ff 00 | …
[tester::#VT6]
[tester::#VT6] Hexdump of received “DescribeTopicPartitions” response:
[tester::#VT6] Idx | Hex | ASCII
[tester::#VT6] -----±------------------------------------------------±----------------
[tester::#VT6] 0000 | 00 00 00 39 66 1b 0b bf 00 00 00 00 00 00 00 01 | …9f…
[tester::#VT6] 0010 | 00 03 11 75 6e 6b 6e 6f 77 6e 2d 74 6f 70 69 63 | …unknown-topic
[tester::#VT6] 0020 | 2d 73 61 7a 00 00 00 00 00 00 00 00 00 00 00 00 | -saz…
[tester::#VT6] 0030 | 00 00 00 00 00 00 ff ff ff ff 00 ff 00 | …
[tester::#VT6]
[tester::#VT6] [Decoder] - .ResponseHeader
[tester::#VT6] [Decoder] - .correlation_id (1713048511)
[tester::#VT6] [Decoder] - .TAG_BUFFER
[tester::#VT6] [Decoder] - .ResponseBody
[tester::#VT6] [Decoder] - .throttle_time_ms (0)
[tester::#VT6] [Decoder] - .topic.length (0)
[tester::#VT6] [Decoder] - .next_cursor
[tester::#VT6] [Decoder] - .topic_name ()
[tester::#VT6] [Decoder] - .partition_index (201077)
[tester::#VT6] Received:
[tester::#VT6] Hex (bytes 14-29) | ASCII
[tester::#VT6] ------------------------------------------------±-----------------
[tester::#VT6] 11 75 6e 6b 6e 6f 77 6e 2d 74 6f 70 69 63 2d 73 | .unknown-topic-s
[tester::#VT6] ^ ^
[tester::#VT6] Error: Expected length to be lesser than remaining bytes (38), got 110
[tester::#VT6] Context:
[tester::#VT6] - DescribeTopicPartitions v0
[tester::#VT6] - Response Body
[tester::#VT6] - next_cursor
[tester::#VT6] - TAG_BUFFER
[tester::#VT6] - TAGGED_FIELD_ARRAY
[tester::#VT6] - RAW_BYTES
[tester::#VT6]
[tester::#VT6] Test failed
[tester::#VT6] Terminating program
[tester::#VT6] Program terminated successfull


I have thought I completely matched a format described in the link of the task

Tasks under construction are so messy, “return a response as this but skip this, here’s a binary scheme doc, here’s an apache doc, and here are tests that are completely different than all aforementioned”

Can anybody tell how evaluation happens, are [decoder] messages an expected output format?

What this error means?

Hey @hrabkin, could you upload your code to GitHub and share the link? It will be much easier to debug if I can run it directly.

@andy1li thanks, yes sure, it is here

@hrabkin The [decoder] messages are just our best attempt at decoding your response. They aren’t part of the expected format.

There may be a couple of issues. The first one I see is that topic.length is incorrect:

Let me know if you’d like any further clarification!

@andy1li thanks I think I have figured out problems I had, there were two major: 1. len of topics array and topic name should be in uvarint format (binary.AppendUvarint), 2. Error code for handling unsupported ApiVersions was included for all api requests but version 75 has its response header format.

1 Like

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