Question about ea7: Test server panic

I haven’t had a chance to dig into the root cause yet, and my solution is not complete, but my current implementation is causing a panic on the tester application.
I’m submitting this question mainly as feedback and to highlight an example of a response that causes a panic. It’s less about seeking help on my solution and more about contributing to the discussion. Hope this is helpful

[tester::#EA7] Sending "DescribeTopicPartitions" (version: 0) request (Correlation id: 1455906278)
[tester::#EA7] Hexdump of sent "DescribeTopicPartitions" request: 
[tester::#EA7] Idx  | Hex                                             | ASCII
[tester::#EA7] -----+-------------------------------------------------+-----------------
[tester::#EA7] 0000 | 00 00 00 23 00 4b 00 00 56 c7 5d e6 00 0c 6b 61 | ...#.K..V.]...ka
[tester::#EA7] 0010 | 66 6b 61 2d 74 65 73 74 65 72 00 02 04 62 61 72 | fka-tester...bar
[tester::#EA7] 0020 | 00 00 00 00 01 ff 00                            | .......
[tester::#EA7] Hexdump of received "DescribeTopicPartitions" response: 
[tester::#EA7] Idx  | Hex                                             | ASCII
[tester::#EA7] -----+-------------------------------------------------+-----------------
[tester::#EA7] 0000 | 00 00 00 39 56 c7 5d e6 00 00 00 00 00 02 00 00 | ...9V.].........
[tester::#EA7] 0010 | 04 62 61 72 00 00 00 00 00 00 40 00 80 00 00 00 | .bar......@.....
[tester::#EA7] 0020 | 00 00 00 56 00 02 00 00 00 00 00 00 00 00 00 00 | ...V............
[tester::#EA7] 0030 | 02 02 02 02 02 00 00 00 00 00 00 ff 00          | .............
[tester::#EA7] 
[tester::#EA7] [Decoder] - .ResponseHeader
[tester::#EA7] [Decoder]   - .correlation_id (1455906278)
[tester::#EA7] [Decoder]   - .TAG_BUFFER
[tester::#EA7] [Decoder] - .ResponseBody
[tester::#EA7] [Decoder]   - .throttle_time_ms (0)
[your_program] read 39 bytes from request
[your_program] wrote response of len 57
[tester::#EA7] [Decoder]   - .topic.length (1)
[tester::#EA7] [Decoder]   - .Topics[0]
[tester::#EA7] [Decoder]     - .error_code (0)
[tester::#EA7] [Decoder]     - .name (bar)
[tester::#EA7] [Decoder]     - .topic_id (00000000-0000-4000-8000-000000000056)
[tester::#EA7] [Decoder]     - .is_internal (false)
[tester::#EA7] [Decoder]     - .num_partitions (1)
[tester::#EA7] [Decoder]     - .Partitions[0]
[tester::#EA7] [Decoder]       - .error_code (0)
[tester::#EA7] [Decoder]       - .partition_index (0)
[tester::#EA7] [Decoder]       - .leader_id (0)
[tester::#EA7] [Decoder]       - .leader_epoch (33686018)
[tester::#EA7] [Decoder]       - .replica_nodes ([0])
[tester::#EA7] [Decoder]       - .isr_nodes ([])
[tester::#EA7] [Decoder]       - .eligible_leader_replicas ([])
panic: runtime error: index out of range [3] with length 0

goroutine 3 [running]:
encoding/binary.bigEndian.Uint32(...)
        /opt/hostedtoolcache/go/1.22.10/x64/src/encoding/binary/binary.go:161
github.com/codecrafters-io/kafka-tester/protocol/decoder.(*RealDecoder).GetCompactInt32Array(0xc000159b08)
        /home/runner/work/kafka-tester/kafka-tester/protocol/decoder/real_decoder.go:355 +0x1ee
github.com/codecrafters-io/kafka-tester/protocol/api.(*DescribeTopicPartitionsResponsePartition).Decode(0xc0001598c8, 0xc000159b08, 0xc00011c1e0, 0x3)
        /home/runner/work/kafka-tester/kafka-tester/protocol/api/describe_topic_partitions_response.go:243 +0xb78
github.com/codecrafters-io/kafka-tester/protocol/api.(*DescribeTopicPartitionsResponseTopic).Decode(0xc0001599f8, 0xc000159b08, 0xc00011c1e0, 0x2)
        /home/runner/work/kafka-tester/kafka-tester/protocol/api/describe_topic_partitions_response.go:140 +0xb9a
github.com/codecrafters-io/kafka-tester/protocol/api.(*DescribeTopicPartitionsResponse).Decode(0xc0000a6040, 0xc000159b08, 0xc00011c1e0, 0x1)
        /home/runner/work/kafka-tester/kafka-tester/protocol/api/describe_topic_partitions_response.go:43 +0x4ba
github.com/codecrafters-io/kafka-tester/protocol/api.DecodeDescribeTopicPartitionsHeaderAndResponse({0xc0000a8000?, 0x5e6408?, 0xc00011c1e0?}, 0xc00011c1e0)
        /home/runner/work/kafka-tester/kafka-tester/protocol/api/describe_topic_partitions.go:57 +0x44e
github.com/codecrafters-io/kafka-tester/internal.testDTPartitionWithTopicAndSinglePartition(0xc000066c60)
        /home/runner/work/kafka-tester/kafka-tester/internal/stagep3.go:60 +0x5fe
github.com/codecrafters-io/tester-utils/test_runner.TestRunner.Run.func1()
        /home/runner/go/pkg/mod/github.com/codecrafters-io/tester-utils@v0.2.40/test_runner/test_runner.go:57 +0x28
created by github.com/codecrafters-io/tester-utils/test_runner.TestRunner.Run in goroutine 1
        /home/runner/go/pkg/mod/github.com/codecrafters-io/tester-utils@v0.2.40/test_runner/test_runner.go:56 +0x3d0
CodeCrafters internal error: exit status 2

Hi @harveysanders, thanks for your feedback! We’ll investigate the issue and keep you updated on any changes.

1 Like