fix(core): resolve kebab env vars as snake case#62
Open
AlexProgrammerDE wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR improves environment-variable preprocessing to support kebab-case config keys being overridden by snake_case environment variable names (e.g., encryption-key → ENCRYPTION_KEY).
Changes:
- Refactors env-var name construction into a helper method in
RootSerializer. - Normalizes generated env-var names by replacing
-with_. - Adds a regression test covering LOWER_KEBAB_CASE config names with snake_case environment variables.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| configlib-core/src/main/java/de/exlll/configlib/RootSerializer.java | Centralizes env-var name creation and adds -→_ normalization for kebab-case paths. |
| configlib-core/src/test/java/de/exlll/configlib/RootSerializerTest.java | Adds a test and supporting records to validate kebab-case key overrides via snake_case env vars. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+101
to
+109
| private String createEnvironmentVariable(String prefix, String pathSegment) { | ||
| String envVar = prefix.isEmpty() | ||
| ? pathSegment | ||
| : prefix + '_' + pathSegment; | ||
| envVar = envVar.replace('-', '_'); | ||
| return envVarConfig.caseSensitive() | ||
| ? envVar | ||
| : envVar.toUpperCase(Locale.ROOT); | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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
Why
Lower-kebab formatted config keys such as
encryption-keypreviously generated environment variable names likeENCRYPTION-KEY, which cannot be used as normal environment variables on many systems. This keeps kebab-case config files while allowingENCRYPTION_KEYstyle overrides.Validation
JAVA_HOME=/tmp/codex-jdk21 PATH=/tmp/codex-jdk21/bin:$PATH ./gradlew :configlib-core:checkDisclosure
This PR was made with Codex GPT-5.5 medium fast.
And yes this is a real bug I have in my production plugins.