Skip to content

fix(core): resolve kebab env vars as snake case#62

Open
AlexProgrammerDE wants to merge 2 commits into
Exlll:devfrom
6b6t:master
Open

fix(core): resolve kebab env vars as snake case#62
AlexProgrammerDE wants to merge 2 commits into
Exlll:devfrom
6b6t:master

Conversation

@AlexProgrammerDE
Copy link
Copy Markdown
Contributor

@AlexProgrammerDE AlexProgrammerDE commented May 19, 2026

Summary

  • Normalize generated environment variable names by replacing dashes with underscores before lookup.
  • Add a regression test for lower-kebab configuration keys resolving from snake_case environment variables.

Why

Lower-kebab formatted config keys such as encryption-key previously generated environment variable names like ENCRYPTION-KEY, which cannot be used as normal environment variables on many systems. This keeps kebab-case config files while allowing ENCRYPTION_KEY style overrides.

Validation

  • JAVA_HOME=/tmp/codex-jdk21 PATH=/tmp/codex-jdk21/bin:$PATH ./gradlew :configlib-core:check

Disclosure

This PR was made with Codex GPT-5.5 medium fast.
And yes this is a real bug I have in my production plugins.

@AlexProgrammerDE AlexProgrammerDE marked this pull request as ready for review May 19, 2026 15:33
Copilot AI review requested due to automatic review settings May 19, 2026 15:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-keyENCRYPTION_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 thread configlib-core/src/test/java/de/exlll/configlib/RootSerializerTest.java Outdated
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>
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.

2 participants