Fix IndexOutOfBoundsException in Family branch accessors for families without a stripped branch#1207
Open
Arilas wants to merge 1 commit into
Open
Conversation
… without a stripped branch Family.getBranchBlock(int)/getBranchItem(int) index straight into the branches list, so any family that has no stripped branch entry (common for add-on tree pack families) crashes consumers of getStrippedBranch() with "Index 1 out of bounds for length 1" during client model handling. Bounds-check the index and return Optional.empty(), honoring the accessors' Optional contract. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Family.getBranchBlock(int)andFamily.getBranchItem(int)index directly into thebrancheslist. Any family that has no stripped branch entry (onlyBRANCH_INDEXpopulated) throws whengetStrippedBranch()is called:This is easy to hit in practice: several add-on tree pack families (e.g. from dtbop / dtterralith) register families without stripped branches, and any client-side code that walks families and asks for the stripped branch (model handling does) crashes repeatedly during model bake.
Fix
Bounds-check the index in the two protected accessors and return
Optional.empty(), which is what theirOptionalreturn type already promises: "no such branch". No signature changes; callers that useifPresent/mapnow behave correctly for families lacking a stripped branch.Found while running a Fabric build in a full production instance with add-on tree packs.
🤖 Generated with Claude Code