Skip to content

JsonOrStringParameterProcessor fails if a parameter contains a single value that is a bool or number #247

@a-jackson

Description

@a-jackson

Describe the bug

Using the JsonOrStringParameterProcessor if I have a parameter that is a single value which is a json primitive then an ArgumentNullException is thrown, as this isn't a JsonException is does not fallback to handling the parameter as a string.

The error specifically is from JsonConfigurationParser.VisitPrimitive because _currentPath is null.

I was hoping that swapping from DefaultParameterProcessor to JsonOrStringParameterProcessor would be backwards compatible but due to this it isn't.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

JsonOrStringParameter processor should be able to handle single parameters with a Json primitive as the only value, i.e. not an object or array.

Current Behavior

Handled ArgumentNullException

Reproduction Steps

Create a parameter /some/path/value = true and then

configurationBuilder.AddSystemsManager(options => {
  options.Path = "/some/path";
  options.ParameterProcessor = new JsonOrStringParameterProcessor();
});

Possible Solution

If the root is a primitive either fallback to the string processor or gracefully handle _currentPath being null with an empty string. Not tested either option.

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Amazon.Extensions.Configuration.SystemsManager v7.0.1

Targeted .NET Platform

.Net 9

Operating System and version

Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions