Skip to content

DuplicateParameterException can break a production application #184

@tysonstewart

Description

@tysonstewart

Describe the bug

The extension throws a DuplicateParameterException when a "duplicate" parameter is detected because the keys are case-insensitive in code but case-sensitive in Parameter Store. This means that an application that uses this extension on startup as describe in the documentation can be prevented from starting simply by adding a key to Parameter Store--no code changes.

Expected Behavior

The extension should gracefully handle a duplicate key, probably by letting the last value win since .NET configuration works that way anyway.

Current Behavior

The extension throws an exception. Handling the exception isn't really an option since the rest of the configuration won't be available.

Reproduction Steps

  1. Add a value to Parameter Store, e.g. /myApp/myKey
  2. Add the prefix to the configuration using the application extension method:
    builder.Configuration.AddSystemsManager("/myApp");
  3. Optionally start the app to show that it works
  4. Add a new value to Parameter Store having the same key as step 1 but with different casing, e.g. /myApp/mykey
  5. Restart the app and note that it throws a DuplicateParameterException on startup

Possible Solution

I don't consider the addition of a configuration parameter to be an action that could cause an application to fail to start. While the conflict in keys is something I would definitely want to know about, I don't want the application to not start at least in production. My suggested behavior is allowing the last value to win, though perhaps the exact behavior could be configurable itself.

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Amazon.Extensions.Configuration.SystemsManager 6.2.0

Targeted .NET Platform

.NET Core 7.0

Operating System and version

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.module/sys-mgr-extp2This is a standard priority issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions