configuration-as-code-plugin icon indicating copy to clipboard operation
configuration-as-code-plugin copied to clipboard

CasC allows duplicate entries for single valued Describables without warning.

Open jtnord opened this issue 1 year ago • 6 comments

Jenkins and plugins versions report

Environment

from https://github.com/jenkinsci/oic-auth-plugin/issues/436 , otherwise unknown

What Operating System are you using (both controller, and any agents involved in the problem)?

N/A

Reproduction steps

  1. Create a config as code snippet with 2 different conflicting options for a describable.

e.g.

jenkins:
  securityRealm:
    oic:
      serverConfiguration:
        # Automatic config of endpoint
        wellKnown:
          wellKnownOpenIDConfigurationUrl: "https://myid.com/.well-known/openid-configuration"
        # Manual config of endpoint
        manual:
          authorizationServerUrl: "https://myid.com/authorize"
          issuer: "https://myid.com/"
          jwksServerUrl: "https://myid.com/jwks"
          tokenServerUrl: "https://myid.com/token"
          userInfoServerUrl: "https://myid.com/userInfo"
          useRefreshTokens: false
      # Credentials
      clientId: "myclient-01"
      clientSecret: "supersecret"
      # claims
  1. start Jenkins with this casc file

serverConfiguration is a single valued Describable, yet the config contains two conflicting values for the above.

Expected Results

the startup should error or warn as the configuration is invalid

Actual Results

no warning / error

Anything else?

No response

jtnord avatar Nov 04 '24 11:11 jtnord

You don't happen to have the merge strategy enabled?

https://github.com/jenkinsci/configuration-as-code-plugin/blob/8b9efc1b9026942064d5248c92bf89cb00f83ea0/docs/features/mergeStrategy.md

timja avatar Nov 04 '24 12:11 timja

is this issue open ? assign me if open

iihimanshuu avatar Jan 31 '25 16:01 iihimanshuu

Assign to me? I will work on it.

shivammm21 avatar Apr 02 '25 09:04 shivammm21

We don't assign issues to users, just open a pull request instead and it will be reviewed

timja avatar Apr 02 '25 14:04 timja

ok. so I started working on this issue.

shivammm21 avatar Apr 05 '25 11:04 shivammm21

Thank you for the opportunity to contribute to this project. I've implemented a solution that addresses issue #2589 by detecting duplicate entries in single-valued Describables and providing appropriate feedback to users.

The fix should help prevent confusion when users accidentally include multiple configuration options (like both well-known and manual in the OIC plugin example) for components that should only have one configuration approach.

I've included comprehensive tests to verify both the warning behavior in normal mode and the exception throwing in strict mode. Please let me know if you'd like to see any adjustments to the implementation approach.

shivammm21 avatar Apr 05 '25 18:04 shivammm21