# \[Java\]\[#MG6\] zlib error after parsing many objects successfully

**URL:** <https://forum.codecrafters.io/t/java-mg6-zlib-error-after-parsing-many-objects-successfully/6363>\
**Category:** Challenges\
**Tags:** challenge:git\
**Created:** [March 9, 2025, 3:46pm UTC](https://forum.codecrafters.io/t/java-mg6-zlib-error-after-parsing-many-objects-successfully/6363 "2025-03-09T15:46:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![HowieTKL](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/howietkl/32/5687_2.png) [@HowieTKL](https://forum.codecrafters.io/u/HowieTKL)\
**Post date:** [March 9, 2025, 3:46pm UTC](https://forum.codecrafters.io/t/java-mg6-zlib-error-after-parsing-many-objects-successfully/6363/1 "2025-03-09T15:46:12Z")

</div>

I’m stuck on the last Stage #MG6 while parsing Pack objects I get an inflation error after successfully parsing dozens or even over a hundred objects.

Failure is consistently in the same spot for a given repo. But otherwise no pattern I can determine - I’ve seen it fail for blob, tree & commit objects. My logic for deltified objects are also enough so I can carry on parsing, albeit incomplete. Typically no errors for extremely simple repos with short history.

Seems like I’m missing a special case. Help!

Exception below along with some logs that show previous objects were successfully parsed. Relevant code is probably [around this area](https://github.com/HowieTKL/codecrafters-git-java/blob/master/src/main/java/org/howietkl/git/GitPack.java#L142).

```auto
DEBUG org.howietkl.git.GitPack - processObjects objectIndex=103 type=BLOB size=51
DEBUG org.howietkl.git.GitPack - processObjects objectIndex=104 type=BLOB size=59
DEBUG org.howietkl.git.GitPack - processObjects objectIndex=105 type=BLOB size=32
DEBUG org.howietkl.git.GitPack - processObjects objectIndex=106 type=BLOB size=45
DEBUG org.howietkl.git.GitPack - processObjects objectIndex=107 type=TREE size=268
DEBUG org.howietkl.git.GitPack - processObjects objectIndex=108 type=BLOB size=5
java.util.zip.DataFormatException: incorrect header check
	at java.base/java.util.zip.Inflater.inflateBytesBytes(Native Method)
	at java.base/java.util.zip.Inflater.inflate(Inflater.java:400)
	at java.base/java.util.zip.Inflater.inflate(Inflater.java:470)
	at org.howietkl.git.utils.Utils.getInflated(Utils.java:44)
	at org.howietkl.git.GitPack.processUndeltified(GitPack.java:142)
	at org.howietkl.git.GitPack.processObject(GitPack.java:103)
	at org.howietkl.git.GitPack.processObjects(GitPack.java:91)
	at org.howietkl.git.GitPack.process(GitPack.java:73)
	at org.howietkl.git.command.CloneCommand.gitClone(CloneCommand.java:37)
	at org.howietkl.git.command.CloneCommand.execute(CloneCommand.java:21)
	at Main.main(Main.java:24)

```

Things I’ve tried:

- Ruled out varint parsing by testing my lib against that of another challenger.

---

<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:** [March 9, 2025, 4:40pm UTC](https://forum.codecrafters.io/t/java-mg6-zlib-error-after-parsing-many-objects-successfully/6363/3 "2025-03-09T16:40:13Z")

</div>

Hey @HowieTKL, looks like you’ve got past the last stage. Congratulations! 🎉

Would you mind sharing what was wrong? Would love to see if we can improve the tester / instructions.

---

<div class="post-metadata">

**Author:** ![HowieTKL](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/howietkl/32/5687_2.png) [@HowieTKL](https://forum.codecrafters.io/u/HowieTKL)\
**Post date:** [March 9, 2025, 4:51pm UTC](https://forum.codecrafters.io/t/java-mg6-zlib-error-after-parsing-many-objects-successfully/6363/4 "2025-03-09T16:51:33Z")

</div>

It’s still a problem! I just added code to ignore the failure, and try to reconstitute the repo with reduced information… just happens to be enough to pass the test. If anyone has any ideas, I still want to fix it.

---

<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:** [March 17, 2025, 7:39am UTC](https://forum.codecrafters.io/t/java-mg6-zlib-error-after-parsing-many-objects-successfully/6363/6 "2025-03-17T07:39:31Z")

</div>

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

---

<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:** [March 22, 2025, 7:45am UTC](https://forum.codecrafters.io/t/java-mg6-zlib-error-after-parsing-many-objects-successfully/6363/8 "2025-03-22T07:45:58Z")

</div>

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