# Question about stage EG2 - Fetch Single message from Disk

**URL:** https://forum.codecrafters.io/t/question-about-stage-eg2-fetch-single-message-from-disk/15373
**Category:** Challenges
**Tags:** challenge:kafka
**Created:** [October 7, 2025, 7:30pm UTC](https://forum.codecrafters.io/t/question-about-stage-eg2-fetch-single-message-from-disk/15373 "2025-10-07T19:30:56Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![rajneeshks](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/rajneeshks/32/424_2.png) [@rajneeshks](https://forum.codecrafters.io/u/rajneeshks)
#### Post date: [October 7, 2025, 7:30pm UTC](https://forum.codecrafters.io/t/question-about-stage-eg2-fetch-single-message-from-disk/15373/1 "2025-10-07T19:30:57Z")

</div>

I keep getting this error - what is that I am doing wrong?

[tester::#EG2] [client] Hexdump of received “Fetch” response:  
[tester::#EG2] [client] Idx | Hex | ASCII  
[tester::#EG2] [client] -----±------------------------------------------------±----------------  
[tester::#EG2] [client] 0000 | 00 00 00 91 29 fa 4f 2a 00 00 00 00 00 00 00 00 | …).O\*…  
[tester::#EG2] [client] 0010 | 00 00 00 02 71 a5 9a 51 89 68 4f 8b 93 7e c5 2d | …q..Q.hO..~.-  
[tester::#EG2] [client] 0020 | 86 e0 e4 56 02 00 00 00 00 00 00 00 00 00 00 00 | …V…  
[tester::#EG2] [client] 0030 | 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | …  
[tester::#EG2] [client] 0040 | 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 | …  
[tester::#EG2] [client] 0050 | 00 00 00 00 3d 00 00 00 00 02 56 5c 25 ed 00 00 | …=…V%…  
[tester::#EG2] [client] 0060 | 00 00 00 00 00 00 01 91 e0 5b 6d 8b 00 00 01 91 | …[m…  
[tester::#EG2] [client] 0070 | e0 5b 6d 8b 00 00 00 00 00 00 00 00 00 00 00 00 | .[m…  
[tester::#EG2] [client] 0080 | 00 00 00 00 00 01 16 00 00 00 01 0a 61 70 70 6c | …appl  
[tester::#EG2] [client] 0090 | 65 01 00 00 00 | e…  
[tester::#EG2] [client]  
[tester::#EG2] [Decoder] - FetchResponse  
[tester::#EG2] [Decoder] - Header  
[tester::#EG2] [Decoder] - CorrelationID (704270122)  
[tester::#EG2] [Decoder] - Body  
[tester::#EG2] [Decoder] - ThrottleTimeMS (0)  
[tester::#EG2] [Decoder] - ErrorCode (0)  
[tester::#EG2] [Decoder] - SessionID (0)  
[tester::#EG2] [Decoder] - Topics  
[tester::#EG2] [Decoder] - Length (2 (Array length(1) + 1))  
[tester::#EG2] [Decoder] - Topics[0]  
[tester::#EG2] [Decoder] - UUID (71a59a51-8968-4f8b-937e-c52d86e0e456)  
[tester::#EG2] [Decoder] - Partitions  
[tester::#EG2] [Decoder] - Length (2 (Array length(1) + 1))  
[tester::#EG2] [Decoder] - Partitions[0]  
[tester::#EG2] [Decoder] - Id (0)  
[tester::#EG2] [Decoder] - ErrorCode (0)  
[tester::#EG2] [Decoder] - HighWaterMark (0)  
[tester::#EG2] [Decoder] - LastStableOffset (0)  
[tester::#EG2] [Decoder] - LogStartOffset (0)  
[tester::#EG2] [Decoder] - AbortedTransactions  
[tester::#EG2] [Decoder] - Length (0 (Null array))  
[tester::#EG2] [Decoder] - PreferredReadReplica (0)  
[tester::#EG2] [Decoder] - RecordBatches  
[tester::#EG2] [Decoder] - Size (2 (Record size(1) + 1))  
[tester::#EG2] [Decoder] - RecordBatches[0]  
[tester::#EG2] [Decoder] - Offset (0)  
[tester::#EG2] [Decoder] - Length (61)  
[tester::#EG2] [Decoder] - PartitionLeaderEpoch (0)  
[tester::#EG2] [Decoder] - MagicByte (2)  
[tester::#EG2] [Decoder] - CRC (1448879597)  
[tester::#EG2] [Decoder] - Attributes (0)  
[tester::#EG2] [Decoder] - LastOffsetDelta (0)  
[tester::#EG2] [Decoder] - FirstTimeStamp (1726045973899)  
[tester::#EG2] [Decoder] - MaxTimeStamp (1726045973899)  
[tester::#EG2] [Decoder] - ProducerID (0)  
[tester::#EG2] [Decoder] - ProducerEpoch (0)  
[tester::#EG2] [Decoder] - BaseSequence (0)  
[tester::#EG2] [Decoder] - Records  
[tester::#EG2] [Decoder] - Length (1)  
[tester::#EG2] [Decoder] - Records[0]  
[tester::#EG2] [Decoder] - Record  
[tester::#EG2] [Decoder] - Length (11)  
[tester::#EG2] [Decoder] - Attributes (0)  
[tester::#EG2] [Decoder] - TimestampDelta (0)  
[tester::#EG2] [Decoder] - OffsetDelta (0)  
[tester::#EG2] [Decoder] - KeyLength (-1)  
[tester::#EG2] [Decoder] - ValueLength (5)  
[tester::#EG2] [Decoder] - Value ([97 112 112 108 101] → UTF-8: (apple))  
[tester::#EG2] [Decoder] - HeadersLength (-1)  
[tester::#EG2] [Decoder] ❌ RecordBatches (decode error)  
[tester::#EG2] Received bytes:  
[tester::#EG2] Hex (bytes 137-144) | ASCII  
[tester::#EG2] ------------------------------------------------±-----------------  
[tester::#EG2] 70 70 6c 65 01 00 00 00 | pple…  
[tester::#EG2] ^ ^  
[tester::#EG2] Expected recordbatches size to be 73, got 1  
[tester::#EG2] Test failed  
[tester::#EG2] Terminating program  
[your\_program] received 0 bytes, closing this socket!!  
[tester::#EG2] Program terminated successfully

---

<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: [October 8, 2025, 1:35am UTC](https://forum.codecrafters.io/t/question-about-stage-eg2-fetch-single-message-from-disk/15373/4 "2025-10-08T01:35:31Z")

</div>

Hey @rajneeshks, could you [upload your code to GitHub](https://docs.codecrafters.io/features/publish-to-github) and share the link? It will be much easier to debug if I can run it directly.

---

<div class="post-metadata">

### Author: ![rajneeshks](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/rajneeshks/32/424_2.png) [@rajneeshks](https://forum.codecrafters.io/u/rajneeshks)
#### Post date: [October 8, 2025, 3:48am UTC](https://forum.codecrafters.io/t/question-about-stage-eg2-fetch-single-message-from-disk/15373/6 "2025-10-08T03:48:24Z")

</div>

Hi @andy1li - uploaded to github:

> **[GitHub - saingarhia/codecrafters-kafka-rust](https://github.com/saingarhia/codecrafters-kafka-rust/tree/main)**
>
> main

Specific code block that manages the response:

> <https://github.com/saingarhia/codecrafters-kafka-rust/blob/5527d665d7d2ec63a647e348bde4db83d2ea9f22/src/kafka/fetch.rs#L235>

---

<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: [October 8, 2025, 3:16pm UTC](https://forum.codecrafters.io/t/question-about-stage-eg2-fetch-single-message-from-disk/15373/8 "2025-10-08T15:16:38Z")

</div>

@rajneeshks The issue is caused by the hardcoded RecordBatches size:

> <https://github.com/saingarhia/codecrafters-kafka-rust/blob/5527d665d7d2ec63a647e348bde4db83d2ea9f22/src/kafka/fetch.rs#L279-L280>

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/4/d/4d7392cf52a21dccbb29098b9278a750ec8e9ee2.png)

Please note that RecordBatches are of type `COMPACT_RECORDS`:

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/d/d0a079441fc5d9f5f19a38cf1a6505449f48b107.png)

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/2X/b/ba45c67877efe4fcd0cf4004e9c2f9c2b4199c3e.png)

Let me know if you’d like further clarification!

---

<div class="post-metadata">

### Author: ![CodeWithDawood](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/codewithdawood/32/18278_2.png) [@CodeWithDawood](https://forum.codecrafters.io/u/CodeWithDawood)
#### Post date: [October 9, 2025, 9:02am UTC](https://forum.codecrafters.io/t/question-about-stage-eg2-fetch-single-message-from-disk/15373/10 "2025-10-09T09:02:59Z")

</div>

quite helpfull

---

<div class="post-metadata">

### Author: ![CodeWithDawood](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/codewithdawood/32/18278_2.png) [@CodeWithDawood](https://forum.codecrafters.io/u/CodeWithDawood)
#### Post date: [October 9, 2025, 9:04am UTC](https://forum.codecrafters.io/t/question-about-stage-eg2-fetch-single-message-from-disk/15373/11 "2025-10-09T09:04:09Z")

</div>

yup

> ****
>
> This text will be hidden

---

<div class="post-metadata">

### Author: ![rajneeshks](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/rajneeshks/32/424_2.png) [@rajneeshks](https://forum.codecrafters.io/u/rajneeshks)
#### Post date: [October 9, 2025, 7:10pm UTC](https://forum.codecrafters.io/t/question-about-stage-eg2-fetch-single-message-from-disk/15373/12 "2025-10-09T19:10:25Z")

</div>

that helped, thank you so much!

---

<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: [October 14, 2025, 7:11pm UTC](https://forum.codecrafters.io/t/question-about-stage-eg2-fetch-single-message-from-disk/15373/13 "2025-10-14T19:11:24Z")

</div>

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