fix(config): use SnakeYAML default ctor (2.x compatible) for existing-config load - #159
Merged
Merged
Conversation
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.
Source: Discord ask-support thread
Root cause: 0.15.10 (PR #157, commit 4932eb4) added
new Yaml(new SafeConstructor())inConfigLoader.hasBedrockIdentitySection. SnakeYAML 2.0 removed the no-argSafeConstructorconstructor, and Velocity 4.x supplies SnakeYAML 2.x at runtime (through Configurate) — the velocity module declares snakeyaml asprovided, so the plugin jar does not bundle it. Every existing-config.yml load on Velocity therefore crashed withNoSuchMethodError: org.yaml.snakeyaml.constructor.SafeConstructor: method 'void <init>()' not found, wrapped in the misleadingRuntimeException: Failed to load the config! Try to delete the config file.... Deleting config.yml does not help — the crash only fires when a config.yml exists. Spigot/Bungee platforms (SnakeYAML 1.x) were unaffected; 0.15.9 and earlier had no such code path.Fix: construct
new Yaml()— the default constructor delegates to SafeConstructor internally in both SnakeYAML 1.x and 2.x. No project-wide 2.x API bump is needed: a repo-wide grep shows this was the only productionnew SafeConstructor()/ non-defaultnew Yaml(...)usage (the othernew Yaml(call sites are release-verification tests already on the default ctor, which is safe on both APIs).Regression coverage (TDD RED → GREEN):
core/build.gradle.kts: core test classpath now pins SnakeYAML 2.2 (the major version Velocity actually provides at runtime), so the config-loading tests exercise the platform API instead of the compile-time 1.28.ConfigLoaderTest.legacyConfigLoadsOnSnakeYaml2xRuntimeClasspathfails on the unfixed code with the exact production signature —Caused by: java.lang.NoSuchMethodError: org.yaml.snakeyaml.constructor.SafeConstructor: method 'void <init>()' not foundatConfigLoader.java:74— and passes on the fix.:core:testsuite: 67 classes / 347 tests / 0 failures / 0 errors (all 8 ConfigLoaderTest cases green on the 2.x classpath).