# Issue with List for a single partition #EA7

**URL:** <https://forum.codecrafters.io/t/issue-with-list-for-a-single-partition-ea7/15798>\
**Category:** Challenges\
**Tags:** challenge:kafka\
**Created:** [January 18, 2026, 10:50am UTC](https://forum.codecrafters.io/t/issue-with-list-for-a-single-partition-ea7/15798 "2026-01-18T10:50:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![woutervanveen](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/woutervanveen/32/18015_2.png) [@woutervanveen](https://forum.codecrafters.io/u/woutervanveen)\
**Post date:** [January 18, 2026, 10:50am UTC](https://forum.codecrafters.io/t/issue-with-list-for-a-single-partition-ea7/15798/1 "2026-01-18T10:50:27Z")

</div>

Hi all,

I might be missing something, so please let me know. At the moment I am trying to parse the cluster metadata file with several batches inside. I noticed however that the record batch one has a length parameter which is a single byte, and in record batch 2 the length is a double byte. I am struggeling a bit with which one is correct, or if I should be able to detect this somehowe from the message (or length) itself. Can somebody give me a pointer on this?

Thank you!

Wouter van Veen

---

<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:** [January 18, 2026, 11:26am UTC](https://forum.codecrafters.io/t/issue-with-list-for-a-single-partition-ea7/15798/4 "2026-01-18T11:26:31Z")

</div>

Hey @woutervanveen, could you use [BinspecVisualizer](https://binspec.org/kafka-cluster-metadata) and share a screenshot of the specific fields you’re referring to? Thanks!

---

<div class="post-metadata">

**Author:** ![woutervanveen](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/woutervanveen/32/18015_2.png) [@woutervanveen](https://forum.codecrafters.io/u/woutervanveen)\
**Post date:** [January 18, 2026, 11:49am UTC](https://forum.codecrafters.io/t/issue-with-list-for-a-single-partition-ea7/15798/6 "2026-01-18T11:49:42Z")

</div>

That was quick!

This is the length of record 1:

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/0/0/00d7b24e4aa5c5ecfa185e3121ad209f5471db19.png)

I wanted to put a screenshot of the second batch second record, but I am limited to a single screenshot, so I will put it in the next post

---

<div class="post-metadata">

**Author:** ![woutervanveen](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/woutervanveen/32/18015_2.png) [@woutervanveen](https://forum.codecrafters.io/u/woutervanveen)\
**Post date:** [January 18, 2026, 11:50am UTC](https://forum.codecrafters.io/t/issue-with-list-for-a-single-partition-ea7/15798/7 "2026-01-18T11:50:28Z")

</div>

This is the screen shot of the second record of the second batch:

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/8/789038f63ea6f3a8e3152eb20e0fb9dbf960e51d.png)

Actually the length of the first record in the second batch also uses only 1 byte.

---

<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:** [January 18, 2026, 11:59am UTC](https://forum.codecrafters.io/t/issue-with-list-for-a-single-partition-ea7/15798/8 "2026-01-18T11:59:16Z")

</div>

@woutervanveen Ah, gotcha. You’ll want to look into how [varint encoding](https://protobuf.dev/programming-guides/encoding/) works.

Here’re two related posts:

- [Sqlite varint decoding Stage #SZ4 - #2 by andy1li](https://forum.codecrafters.io/t/sqlite-varint-decoding-stage-sz4/1934/2)
- [How to parse variable sized integer from metadata log - #5 by andy1li](https://forum.codecrafters.io/t/how-to-parse-variable-sized-integer-from-metadata-log/4254/5)

Let me know if it still does not make sense after that.

---

<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:** [January 18, 2026, 12:07pm UTC](https://forum.codecrafters.io/t/issue-with-list-for-a-single-partition-ea7/15798/9 "2026-01-18T12:07:00Z")

</div>

Here’s a quick verification of 0x9001 as 72:

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

0x9001 has two bytes:

- `1`001 0000: continue
- `0`000 0001: stop

```auto
001 0000 + 000 0001 reverses order due to endianness:

000 0001 + 001 0000

= 1 001 0000 = 144

```

144 becomes 144 / 2 = 72 due to zig-zag encoding.

---

<div class="post-metadata">

**Author:** ![woutervanveen](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/woutervanveen/32/18015_2.png) [@woutervanveen](https://forum.codecrafters.io/u/woutervanveen)\
**Post date:** [January 18, 2026, 2:55pm UTC](https://forum.codecrafters.io/t/issue-with-list-for-a-single-partition-ea7/15798/10 "2026-01-18T14:55:07Z")

</div>

Thank you! That should be enough information to fix this!

---

<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:** [January 23, 2026, 2:55pm UTC](https://forum.codecrafters.io/t/issue-with-list-for-a-single-partition-ea7/15798/11 "2026-01-23T14:55:07Z")

</div>

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