Skip to content

Don't fail component parsing on unparseable hex colors - #3681

Merged
SirYwell merged 1 commit into
IntellectualSites:mainfrom
fbrandt-dev:cherry-pick/worldedit-3652-hex-colors
Oct 3, 2026
Merged

SirYwell merged 1 commit into
IntellectualSites:mainfrom
fbrandt-dev:cherry-pick/worldedit-3652-hex-colors

Conversation

@fbrandt-dev

Copy link
Copy Markdown
Contributor

Cherry-pick of EngineHub/WorldEdit@1fcbef5 (EngineHub/WorldEdit#3029), applies on top of the approach from #3652.

Running /repl air while holding an item whose custom name contains a hex color (e.g. a menu/gadget item renamed by another plugin) kills the whole command/logs an exception:

[ERROR] PlatformCommandManager: An unexpected error while handling a FastAsyncWorldEdit command
com.google.gson.JsonParseException: Don't know how to parse "#FFD700"
    at com.sk89q.worldedit.util.formatting.text.serializer.gson.TextColorWrapper$Serializer.deserialize(TextColorWrapper.java:56)

Cause: The relocated text library (net.kyori:text 3.0.4) predates MC 1.16 — TextColor is an enum of the 16 legacy color names and cannot represent hex colors at all, while vanilla JSON text has allowed "color": "#RRGGBB" since 1.16.

Fix: The vendored StyleSerializer (already copied and relocated from text3 for the 1.21.5 click/hover event updates) now catches the JsonParseException when the color field cannot be mapped and drops the color instead of failing the whole component — including the debug-level stacktrace and GPL test header from upstream review. The item name is still shown, just uncolored. As the single choke point of the Gson deserializer, this also covers hover event contents and any other component parsed through it.

Verification: :worldedit-core:test full suite green, new StyleSerializerTest (2 tests) covers hex-color drop and named-color regression.

…ites#3029)

* 🐛 fix(gson): Drop unparseable hex colors instead of failing components

Vanilla text components may carry hex colors (#RRGGBB) since 1.16, which
text3 cannot represent. The old TextColorWrapper deserialization threw
JsonParseException and the whole component parse failed.

This drops the unparseable color instead, keeping the text content.
Named colors still parse as before.

* 🐛 fix(gson): Log dropped colors at debug level, add license header

Addresses review feedback on IntellectualSites#3029: keep the parse-failure stacktrace
available at debug level, and add the GPL header to the new test class.

(cherry picked from commit 1fcbef53918675e3edfdda2cd34214232fe9bf10)
Copilot AI balanced review requested due to automatic review settings October 2, 2026 23:36
@fbrandt-dev
fbrandt-dev requested a review from a team as a code owner October 2, 2026 23:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The narrow fallback preserves existing color handling, includes regression tests, and has no identified blocking issues.

Review effort: Balanced
Findings: None

What changed in this PR

Prevents unsupported hex colors in item names from aborting component parsing and WorldEdit commands.

Changes:

  • Drops unparseable colors and logs the exception at debug level.
  • Adds tests for hex-color fallback and named-color preservation.
File Description
worldedit-core/​src/​test/​java/​com/​sk89q/​worldedit/​util/​formatting/​text/​serializer/​gson/​StyleSerializerTest.java Tests unsupported and named color handling.
worldedit-core/​src/​main/​java/​com/​sk89q/​worldedit/​util/​formatting/​text/​serializer/​gson/​StyleSerializer.java Handles color parsing failures without rejecting the component.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@SirYwell SirYwell changed the title Don't fail component parsing on unparseable hex colors (#3029) Don't fail component parsing on unparseable hex colors Oct 3, 2026
@SirYwell
SirYwell enabled auto-merge (squash) October 3, 2026 07:21
@SirYwell
SirYwell merged commit e5c2037 into IntellectualSites:main Oct 3, 2026
5 checks passed
@NotMyFault NotMyFault added the Bugfix This PR fixes a bug label Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugfix This PR fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants