# BYO Kafka - #YK1 Testing for Incorrect Response Header

**URL:** <https://forum.codecrafters.io/t/byo-kafka-yk1-testing-for-incorrect-response-header/11439>\
**Category:** Challenges\
**Created:** [May 31, 2025, 4:12am UTC](https://forum.codecrafters.io/t/byo-kafka-yk1-testing-for-incorrect-response-header/11439 "2025-05-31T04:12:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Didgety](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/didgety/32/12162_2.png) [@Didgety](https://forum.codecrafters.io/u/Didgety)\
**Post date:** [May 31, 2025, 4:12am UTC](https://forum.codecrafters.io/t/byo-kafka-yk1-testing-for-incorrect-response-header/11439/1 "2025-05-31T04:12:46Z")

</div>

```auto
remote: [tester::#YK1] Running tests for Stage #YK1 (Listing Partitions - Include DescribeTopicPartitions in APIVersions)
remote: [tester::#YK1] $ ./your_program.sh /tmp/server.properties
remote: [tester::#YK1] Connecting to broker at: localhost:9092
remote: [tester::#YK1] Connection to broker at localhost:9092 successful
remote: [tester::#YK1] Sending "ApiVersions" (version: 4) request (Correlation id: 1296539330)
remote: [tester::#YK1] Hexdump of sent "ApiVersions" request:
remote: [tester::#YK1] Idx | Hex | ASCII
remote: [tester::#YK1] -----+-------------------------------------------------+-----------------
remote: [tester::#YK1] 0000 | 00 00 00 23 00 12 00 04 4d 47 9e c2 00 09 6b 61 | ...#....MG....ka
remote: [tester::#YK1] 0010 | 66 6b 61 2d 63 6c 69 00 0a 6b 61 66 6b 61 2d 63 | fka-cli..kafka-c
remote: [tester::#YK1] 0020 | 6c 69 04 30 2e 31 00 | li.0.1.
remote: [tester::#YK1]
remote: [tester::#YK1] Hexdump of received "ApiVersions" response:
remote: [tester::#YK1] Idx | Hex | ASCII
remote: [tester::#YK1] -----+-------------------------------------------------+-----------------
remote: [tester::#YK1] 0000 | 00 00 00 1b 4d 47 9e c2 00 00 00 03 00 12 00 03 | ....MG..........
remote: [tester::#YK1] 0010 | 00 04 00 00 4b 00 00 00 00 00 00 00 00 00 00 | ....K..........
remote: [tester::#YK1]
remote: [tester::#YK1] [Decoder] - .ResponseHeader
remote: [tester::#YK1] [Decoder] - .correlation_id (1296539330)
remote: [tester::#YK1] [Decoder] - .ResponseBody
remote: [tester::#YK1] [Decoder] - .error_code (0)
remote: [tester::#YK1] [Decoder] - .num_api_keys (0)
remote: [tester::#YK1] [Decoder] - .throttle_time_ms (50336256)
remote: [tester::#YK1] [Decoder] - .TAG_BUFFER

```

Key bytes: `c2 00 00 00 03 00`, there is an extra `00` before the `03` from the tag buffer in ResponseHeaderV1

The tester sends an ApiVersionsRequestV4 with a RequestHeaderV2 (has tagged fields). I would therefore expect the program to test for a ResponseHeaderV1 (has tagged fields). Instead the program is testing for a ResponseHeaderV0 (no tagged fields).

The other test from this section is testing for a ResponseHeaderV1:

```auto
remote: [tester::#VT6] Running tests for Stage #VT6 (Listing Partitions - List for an unknown topic)
remote: [tester::#VT6] $ ./your_program.sh /tmp/server.properties
remote: [tester::#VT6] Connecting to broker at: localhost:9092
remote: [tester::#VT6] Connection to broker at localhost:9092 successful
remote: [tester::#VT6] Sending "DescribeTopicPartitions" (version: 0) request (Correlation id: 1239075417)
remote: [tester::#VT6] Hexdump of sent "DescribeTopicPartitions" request:
remote: [tester::#VT6] Idx | Hex | ASCII
remote: [tester::#VT6] -----+-------------------------------------------------+-----------------
remote: [tester::#VT6] 0000 | 00 00 00 31 00 4b 00 00 49 da ca 59 00 0c 6b 61 | ...1.K..I..Y..ka
remote: [tester::#VT6] 0010 | 66 6b 61 2d 74 65 73 74 65 72 00 02 12 75 6e 6b | fka-tester...unk
remote: [tester::#VT6] 0020 | 6e 6f 77 6e 2d 74 6f 70 69 63 2d 73 61 7a 00 00 | nown-topic-saz..
remote: [tester::#VT6] 0030 | 00 00 01 ff 00 | .....
remote: [tester::#VT6]
remote: [tester::#VT6] Hexdump of received "DescribeTopicPartitions" response:
remote: [tester::#VT6] Idx | Hex | ASCII
remote: [tester::#VT6] -----+-------------------------------------------------+-----------------
remote: [tester::#VT6] 0000 | 00 00 00 37 49 da ca 59 00 00 00 00 00 02 00 03 | ...7I..Y........
remote: [tester::#VT6] 0010 | 12 75 6e 6b 6e 6f 77 6e 2d 74 6f 70 69 63 2d 73 | .unknown-topic-s
remote: [tester::#VT6] 0020 | 61 7a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | az..............
remote: [tester::#VT6] 0030 | 00 00 00 01 00 00 0d f8 00 ff 00 | ...........
remote: [tester::#VT6]
remote: [tester::#VT6] [Decoder] - .ResponseHeader
remote: [tester::#VT6] [Decoder] - .correlation_id (1239075417)
remote: [tester::#VT6] [Decoder] - .TAG_BUFFER
remote: [tester::#VT6] [Decoder] - .ResponseBody
remote: [tester::#VT6] [Decoder] - .throttle_time_ms (0)
remote: [tester::#VT6] [Decoder] - .topic.length (1)
remote: [tester::#VT6] [Decoder] - .Topics[0]
remote: [tester::#VT6] [Decoder] - .error_code (3)
remote: [tester::#VT6] [Decoder] - .name (unknown-topic-saz)
remote: [tester::#VT6] [Decoder] - .topic_id (00000000-0000-0000-0000-000000000000)
remote: [tester::#VT6] [Decoder] - .is_internal (false)
remote: [tester::#VT6] [Decoder] - .num_partitions (0)
remote: [tester::#VT6] [Decoder] - .topic_authorized_operations (3576)
remote: [tester::#VT6] [Decoder] - .TAG_BUFFER
remote: [tester::#VT6] [Decoder] - .next_cursor (null)
remote: [tester::#VT6] [Decoder] - .TAG_BUFFER
remote: [tester::#VT6] ✓ Correlation ID: 1239075417
remote: [tester::#VT6] ✓ Throttle Time: 0
remote: [tester::#VT6] ✓ TopicResponse[0] Error code: 3
remote: [tester::#VT6] ✓ TopicResponse[0] Topic Name: unknown-topic-saz
remote: [tester::#VT6] ✓ TopicResponse[0] Topic UUID: 00000000-0000-0000-0000-000000000000
remote: [tester::#VT6] Test passed.

```

I could also be making a mistake in how I am choosing my ResponseHeader version, but if it isn’t based on support for \_tagged\_fields it is not obvious to me.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [May 31, 2025, 10:40am UTC](https://forum.codecrafters.io/t/byo-kafka-yk1-testing-for-incorrect-response-header/11439/3 "2025-05-31T10:40:51Z")

</div>

Hey @Didgety, the `ApiVersionsResponse` always uses a **v0** header:

> <https://github.com/apache/kafka/blob/74bebf6e3dfdc9de6894d656bdbbb28a4c33eda8/generator/src/main/java/org/apache/kafka/message/ApiMessageTypeGenerator.java#L351-L357>

---

<div class="post-metadata">

**Author:** ![Didgety](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/didgety/32/12162_2.png) [@Didgety](https://forum.codecrafters.io/u/Didgety)\
**Post date:** [May 31, 2025, 7:19pm UTC](https://forum.codecrafters.io/t/byo-kafka-yk1-testing-for-incorrect-response-header/11439/4 "2025-05-31T19:19:09Z")

</div>

Woops, lost track of that when I refactored everything. Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [June 5, 2025, 7:19pm UTC](https://forum.codecrafters.io/t/byo-kafka-yk1-testing-for-incorrect-response-header/11439/5 "2025-06-05T19:19:38Z")

</div>

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