Skip to content

Fix flattening crash from %0$s in translatable components - #14164

Closed
chirag-gamer wants to merge 1 commit into
PaperMC:mainfrom
chirag-gamer:fix/translatable-zero-arg-index
Closed

Fix flattening crash from %0$s in translatable components#14164
chirag-gamer wants to merge 1 commit into
PaperMC:mainfrom
chirag-gamer:fix/translatable-zero-arg-index

Conversation

@chirag-gamer

Copy link
Copy Markdown

The translatable component flattener computed the argument index as Integer.parseInt(argIdx) - 1, so %0$s yields -1. The guard only checked idx < args.size(), and -1 passes that whenever the component has arguments, so args.get(-1) threw IndexOutOfBoundsException instead of dropping the placeholder like out-of-range positive indices are dropped.

Fixes #14163

The guard is now idx >= 0 && idx < args.size(), matching the existing "drop out-of-range placeholder" behavior. The sequential-argument branch (argPosition++) already only produced non-negative indices, so this only changes the %0$s case.

I reproduced the crash with a small harness (parse %0$s, idx = -1, args.get(-1) throws) and confirmed the fix compiles against the full server. I couldn't add a JUnit regression test for the full flattening path because it needs a language entry whose value actually contains %0$s, which isn't in the shipped translations. Happy to add one if there's a way to inject test language data.

@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue Aug 8, 2026
@github-project-automation github-project-automation Bot moved this from Awaiting review to Closed in Paper PR Queue Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

Translatable components with %0$s throw IndexOutOfBoundsException during flattening

2 participants