Validate database.dialect before opening the connection pool - #102
Merged
Conversation
SQLDialect.valueOf received the raw config value, so a misspelling or a lowercase spelling failed startup with "No enum constant org.jooq.SQLDialect.mariadb" and nothing naming config.yml, after the HikariCP pool had already been built. Parse the value through a package-private helper instead: match it case-insensitively, reject a blank or unknown value with a message that names the key and the two dialects the plugin ships drivers for, and run the check before any resource is opened so a rejected configuration disables the plugin rather than leaving a pool behind. Also reconcile the duplicated ### Fixed heading under [Unreleased], which CONTRIBUTING.md and CLAUDE.md both forbid. Closes #100 Closes #101 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A key absent from the operator's config.yml resolves to the bundled default rather than to null, since JavaPlugin installs the jar's config.yml as the configuration's defaults. Saying that a missing key stops startup was wrong; only an empty or unusable value does. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
|
Self-review rubric, scored against the diff and the
Judgment calls left for a human reviewer, folded in here rather than as inline notes:
Green CI here means the JVM build against H2 passed. It does not exercise the Bukkit startup path this change touches, nor a MariaDB connection; the manual checks in the description are what cover those. This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). |
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.
Summary
database.dialectis now resolved through a package-privateAlternateAccountFinder#parseDialecthelper rather than handed straight to
SQLDialect.valueOf. A blank or unrecognised value isrejected with a message that names the key, quotes the offending value, and gives the two dialects
the plugin ships drivers for; the plugin then disables itself instead of letting the exception
escape
onEnableas a Bukkit stack trace.h2,mariadbandMariaDBare accepted alongside the uppercase spellingsCONFIG.mddocuments. Anyother dialect jOOQ recognises is still accepted, since narrowing the set to
H2andMARIADBwould break an operator running MySQL through the MariaDB driver.
no longer opens a pool first.
### Fixedheading under[Unreleased]inCHANGELOG.mdwas reconciled into onesection, with
### Addedmoved above it.CONTRIBUTING.mdandCLAUDE.mdboth require eachheading to appear at most once, in Keep a Changelog order; CHANGELOG.md has two ### Changed sections under the same release #92 fixed the same shape before and it
had reappeared.
CONFIG.mdnow records the case-insensitive matching and what happens when the key is unusable.Correction carried from triage
An earlier draft of #101 claimed that a key absent from the operator's
config.ymlreachesSQLDialect.valueOf(null). It does not:JavaPlugin#reloadConfiginstalls the jar's bundledconfig.ymlas the configuration's defaults, so an absent key resolves to the shippedH2. Theissue body has been corrected, the null branch is kept as a defensive guard only, and the
CHANGELOG.mdentry describes the reachable failures. The test covering the null branch says thesame thing in a comment rather than implying an operator can reach it.
Test plan
AlternateAccountFinderTestgains seven cases overparseDialect: the two documenteddialects, mixed and lower case, surrounding whitespace, a dialect the plugin ships no driver
for, a null value, a blank value, and an unknown value whose message must quote what was
configured.
./gradlew clean buildcould not be run locally — the sandbox this was written in has only aJDK 21, which Gradle 8.1.1 refuses (
Unsupported class file major version 65), and no JDK 17is reachable there. The
Buildcheck on this pull request's head commit is the anchor forthis change; it must be green before merge.
database.dialecttomariadband confirm startup succeeds; set it topostgresand confirm the startup log namesthe key and the accepted values and that the plugin is disabled rather than throwing; confirm
no connection pool is opened on that rejected path.
Coverage gap
The
Buildworkflow exercises the JVM build against H2 only. It cannot run the Bukkit path thischange touches — the
disablePlugincall and the wiring ofparseDialectintoonEnable— nor aMariaDB connection. Green CI therefore verifies the helper and the existing suite, not the startup
behaviour; the manual step above is what covers that. No migration, schema or encryption path is
touched by this change.
Deferred this cycle
The rest of the open backlog was left alone, with reasons:
mainrequires theBuildcheck. The repository administration API is not reachable from this session, so it stays a
maintainer action.
.github/copilot-instructions.mdis agent-loaded configuration, which is not editedwithout separate maintainer authorisation.
Closes #100
Closes #101
This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).