Skip to content

fix(locale): suppress stack trace for malformed locale files, improve error message#2954

Merged
tastybento merged 1 commit intodevelopfrom
fix/locale-malformed-yaml-stacktrace
Apr 24, 2026
Merged

fix(locale): suppress stack trace for malformed locale files, improve error message#2954
tastybento merged 1 commit intodevelopfrom
fix/locale-malformed-yaml-stacktrace

Conversation

@tastybento
Copy link
Copy Markdown
Member

Summary

  • YamlConfiguration.loadConfiguration(File) is Bukkit's static helper — it internally catches InvalidConfigurationException and logs it at SEVERE with a full stack trace via Bukkit.getLogger(), completely bypassing BentoBox's own try-catch
  • Switch to new YamlConfiguration(); yaml.load(file) so BentoBox owns the exception and can log a clean, actionable message instead
  • Split catch into InvalidConfigurationException (bad YAML) and generic Exception, both now log two clean lines: what went wrong and a note that English will be used as a fallback
  • The locale folder name is included in the message so admins know which addon's file is the culprit

Before:

[ERROR]: Cannot load plugins\BentoBox\locales\Chat\cs.yml
org.bukkit.configuration.InvalidConfigurationException: mapping values are not allowed here
   at org.bukkit.configuration.file.YamlConfiguration.loadFromString(YamlConfiguration.java:112)
   ... 27 more lines of stack trace ...

After:

[BentoBox] Could not load locale file 'Chat/cs.yml': mapping values are not allowed here in 'reader', line 28, column 71: ...
[BentoBox] The file contains invalid YAML. Delete it and restart to regenerate, or fix the syntax. English will be used as a fallback.

Related: BentoBoxWorld/Chat#58 (fixes the specific malformed file that triggered this)
Fixes #2953

Test plan

  • Place a malformed locale YAML file in a locale folder and start the server — verify only clean BentoBox log lines appear, no stack trace
  • Players using the affected locale fall back to English correctly
  • Valid locale files still load normally

🤖 Generated with Claude Code

… error message

YamlConfiguration.loadConfiguration(File) internally catches parse
exceptions and logs them at SEVERE with a full stack trace via
Bukkit.getLogger(), bypassing BentoBox's own try-catch entirely.

Switch to new YamlConfiguration() + load(file) so BentoBox owns the
error handling. Split the catch into InvalidConfigurationException
(bad YAML syntax — tells the admin to delete/fix the file and notes
English fallback) and a generic Exception fallback. Includes the
locale folder name in the message so the admin knows which addon's
file is at fault.

Related: BentoBoxWorld/Chat#58

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@tastybento tastybento merged commit a69e29d into develop Apr 24, 2026
3 checks passed
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.

Could not update locale file 'locales/cs.yml' due to it being malformed

1 participant