Detect duplicate entries in single-valued Describables #2659
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.
Fixes #2589
This PR adds detection for when configuration files contain multiple entries for a single-valued Describable component. Previously the plugin would silently accept this invalid configuration, potentially leading to unexpected behavior as one configuration would override the other without warning.
Problem
When users configure components like the OIC plugin with both
wellKnown
andmanual
server configuration entries, the Configuration as Code plugin accepts both entries despite only one being valid. This causes one option to silently override the other without any warning, leading to confusion and unexpected behavior.Implementation
BaseConfigurator.configure()
method to check for Describable attributescontext.warning()
in normal modeConfiguratorException
in strict mode (when unknown attributes are set to "reject")Technical Details
Testing
Added
DuplicateEntriesDescribableTest.java
with two test methods:shouldWarnOnDuplicateEntries()
: Verifies warning behavior in normal modeshouldRejectDuplicateEntriesInStrictMode()
: Verifies exception behavior in strict modeCreated test components that mimic the described OIC authentication plugin scenario to ensure the fix correctly identifies conflict cases.
Your checklist for this pull request