Skip to content

fix(config): use SnakeYAML default ctor (2.x compatible) for existing-config load - #159

Merged
minekube-ai-engineer[bot] merged 1 commit into
mainfrom
fix/snakeyaml-2x-config-load
Sep 3, 2026
Merged

fix(config): use SnakeYAML default ctor (2.x compatible) for existing-config load#159
minekube-ai-engineer[bot] merged 1 commit into
mainfrom
fix/snakeyaml-2x-config-load

Conversation

@minekube-ai-engineer

Copy link
Copy Markdown

Source: Discord ask-support thread

Root cause: 0.15.10 (PR #157, commit 4932eb4) added new Yaml(new SafeConstructor()) in ConfigLoader.hasBedrockIdentitySection. SnakeYAML 2.0 removed the no-arg SafeConstructor constructor, and Velocity 4.x supplies SnakeYAML 2.x at runtime (through Configurate) — the velocity module declares snakeyaml as provided, so the plugin jar does not bundle it. Every existing-config.yml load on Velocity therefore crashed with NoSuchMethodError: org.yaml.snakeyaml.constructor.SafeConstructor: method 'void <init>()' not found, wrapped in the misleading RuntimeException: 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 production new SafeConstructor() / non-default new Yaml(...) usage (the other new 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.
  • New test ConfigLoaderTest.legacyConfigLoadsOnSnakeYaml2xRuntimeClasspath fails on the unfixed code with the exact production signature — Caused by: java.lang.NoSuchMethodError: org.yaml.snakeyaml.constructor.SafeConstructor: method 'void <init>()' not found at ConfigLoader.java:74 — and passes on the fix.
  • Full :core:test suite: 67 classes / 347 tests / 0 failures / 0 errors (all 8 ConfigLoaderTest cases green on the 2.x classpath).

@minekube-ai-engineer
minekube-ai-engineer Bot merged commit c0f7840 into main Sep 3, 2026
2 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.

0 participants