8000 Validate .conf extension for --config-file option by griffonbyte · Pull Request #47696 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Validate .conf extension for --config-file option - #47696

Merged
shawkins merged 2 commits into
keycloak:mainfrom
griffonbyte:fix/config-file-extension-validation
Apr 7, 2026
Merged

shawkins merged 2 commits into
keycloak:mainfrom
griffonbyte:fix/config-file-extension-validation

Conversation

@griffonbyte
Copy link
Copy Markdown
Contributor

Adds explicit validation to reject configuration files that do not end with the .conf extension.

Previously, using --config-file or KC_CONFIG_FILE with a non-.conf file would silently ignore the file contents because the underlying SmallRye config source loader filters by extension and returns an empty list for unrecognized extensions. There was no indication to the user that their configuration was not being applied.

The validation is added in two places:

  • The CLI option setter in Main.setConfigFile(), which catches the case at parse time
  • The config source file resolution in KeycloakPropertiesConfigSource.InFileSystem.getConfigurationFile(), which catches the case when the path is set via the KC_CONFIG_FILE environment variable

Closes #46978

@griffonbyte
griffonbyte requested review from a team as code owners April 1, 2026 15:23
@griffonbyte
griffonbyte force-pushed the fix/config-file-extension-validation branch from 682672c to b507500 Compare April 1, 2026 15:32
@shawkins
shawkins commented Apr 1, 2026
Copy link
Copy Markdown
Contributor

@griffonbyte the changes make sense, can you also include a test?

@griffonbyte
griffonbyte force-pushed the fix/config-file-extension-validation branch from b507500 to b9c5225 Compare April 1, 2026 16:38
@griffonbyte
Copy link
Copy Markdown
Contributor Author

Good call, added a test. It follows the same pattern as the existing testInvalidConfigFileOption test in StartCommandDistTest -- uses a keycloak.properties file to verify the extension check triggers the expected error message.

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.broker.KcOidcBrokerTest#loginWithExistingUserWithBruteForceEnabled

Keycloak CI - Java Distribution IT (windows-latest - temurin - 17)

org.openqa.selenium.TimeoutException: 
Expected condition failed: waiting for value to contain (ignoring case) "sign in to". Current value: "AUTH_RESPONSE" (tried for 5 second(s) with 500 milliseconds interval)
Build info: version: '4.28.1', revision: '73f5ad48a2'
System info: os.name: 'Windows Server 2025', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.18'
Driver info: org.jboss.arquillian.drone.webdriver.htmlunit.DroneHtmlUnitDriver_ByGraphene
...

Report flaky test

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@shawkins
shawkins force-pushed the fix/config-file-extension-validation branch from 428d936 to deb6ab4 Compare April 3, 2026 19:26
The --config-file option and KC_CONFIG_FILE environment variable
silently ignored configuration files that did not use the .conf
extension. This happened because the underlying SmallRye config
source loader filters by file extension, returning an empty list
for non-.conf files without any indication to the user.

Added explicit validation in both the CLI option setter and the
config source file resolution to reject files that do not end
with .conf, giving the user a clear error message instead of
silently ignoring their configuration.

Closes keycloak#46978

Signed-off-by: Tanner Smith <griffonbyte@proton.me>
Move the .conf extension check before the file existence check in
setConfigFile(). When a file with a wrong extension does not exist
relative to the working directory, the existence check would fire
first, masking the more specific extension validation error.

Closes keycloak#47696

Signed-off-by: Tanner Smith <griffonbyte@proton.me>
@shawkins
shawkins force-pushed the fix/config-file-extension-validation branch from deb6ab4 to 68252be Compare April 7, 2026 14:59
@shawkins shawkins left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks @griffonbyte

@shawkins
shawkins enabled auto-merge (squash) April 7, 2026 15:00
@shawkins
shawkins merged commit c9627d9 into keycloak:main Apr 7, 2026
88 checks passed
@stianst stianst mentioned this pull request Jun 1, 2026
sashyo pushed a commit to tide-foundation/keycloak-IGA that referenced this pull request Jul 20, 2026
* Validate .conf extension for --config-file option

The --config-file option and KC_CONFIG_FILE environment variable
silently ignored configuration files that did not use the .conf
extension. This happened because the underlying SmallRye config
source loader filters by file extension, returning an empty list
for non-.conf files without any indication to the user.

Added explicit validation in both the CLI option setter and the
config source file resolution to reject files that do not end
with .conf, giving the user a clear error message instead of
silently ignoring their configuration.

Closes keycloak#46978

Signed-off-by: Tanner Smith <griffonbyte@proton.me>

* fix: validate config file extension before checking existence

Move the .conf extension check before the file existence check in
setConfigFile(). When a file with a wrong extension does not exist
relative to the working directory, the existence check would fire
first, masking the more specific extension validation error.

Closes keycloak#47696

Signed-off-by: Tanner Smith <griffonbyte@proton.me>

---------

Signed-off-by: Tanner Smith <griffonbyte@proton.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document / validate .conf extension is required for --config-file option

2 participants

0