Skip to content

Handle expansion errors during placeholder parsing - #1249

Open
HP-network wants to merge 1 commit into
PlaceholderAPI:masterfrom
HP-network:fix/expansion-exception-isolation
Open

HP-network wants to merge 1 commit into
PlaceholderAPI:masterfrom
HP-network:fix/expansion-exception-isolation

Conversation

@HP-network

Copy link
Copy Markdown

A throwing expansion currently aborts the entire placeholder parse. Catch expansion exceptions, log the failing placeholder through the expansion logger, and preserve the original token so later placeholders can still be processed.

Adds a regression test for the failure path. Fixes #1107.

@Andre601

Copy link
Copy Markdown
Collaborator

Personally, I feel like it's the responsibility of the expansion to properly handle and deal with exceptions.

From the PoV of PlaceholderAPI is it not expected for an expansion to throw anything on parse, but rather that this is handled gracefully and either a String or null being returned.
Having an expansion throw on parse, breaking the parsing tells me, that this is a failure on the expansion and that it should be reported to whoever made the expansion to get it fixed.

This genuinly feels like a band-aid solution to me.
Maybe PiggyPiglet or Funnycube think different tho.

@HP-network

HP-network commented Sep 13, 2026 •

Copy link
Copy Markdown
Author

Thanks for the feedback. I agree that an expansion should handle its own exceptions, but I think PlaceholderAPI still needs to treat expansion callbacks as a third-party boundary.

onRequest is called from CharsReplacer, and an unchecked exception currently aborts the entire parse. That means one broken expansion can prevent unrelated placeholders in the same string from being resolved; this is the failure described in #1107.

This change does not hide the failure: it logs the exception through the expansion logger, leaves the original placeholder unchanged (the same fallback used when no replacement is returned), and catches Exception rather than Error. The intent is containment, not replacing the need to fix the expansion itself.

Would you prefer a different logging or fallback behavior, or handling this at another layer?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Placeholder parsing does not fail gracefully when exception is thrown by expansion

2 participants