aws-extensions-for-dotnet-cli icon indicating copy to clipboard operation
aws-extensions-for-dotnet-cli copied to clipboard

JSONPath not fully supported in CLI

Open lukeemery opened this issue 4 years ago • 1 comments

Description

Template substitutions use JSONPath, which supports adding filters. Filters may include operators such as the equal sign. The underlying key-value utility will break on every = and ;

Reproduce using dotnet lambda package-ci --output-template test.json --template-substitutions "$.Resources.*.[?(@.Type =~ 'AWS::Serverless::Function')].Properties=test"

Newtonsoft support doc: https://www.newtonsoft.com/json/help/html/QueryJsonSelectTokenJsonPath.htm

Stack Trace

Processing 1 substitutions.
Processing substitution: $.Resources.*.[?(@.Type 
Unknown error executing command: Path ended with open query.
   at Newtonsoft.Json.Linq.JsonPath.JPath.EnsureLength(String message)
   at Newtonsoft.Json.Linq.JsonPath.JPath.ParseSide()
   at Newtonsoft.Json.Linq.JsonPath.JPath.ParseExpression()
   at Newtonsoft.Json.Linq.JsonPath.JPath.ParseQuery(Char indexerCloseChar, Boolean scan)
   at Newtonsoft.Json.Linq.JsonPath.JPath.ParsePath(List`1 filters, Int32 currentPartStartIndex, Boolean query)
   at Newtonsoft.Json.Linq.JsonPath.JPath.ParseMain()
   at Newtonsoft.Json.Linq.JToken.SelectToken(String path, Boolean errorWhenNoMatch)
   at Amazon.Lambda.Tools.LambdaUtilities.ProcessTemplateSubstitions(IToolLogger logger, String templateBody, IDictionary`2 substitutions, String workingDirectory) in C:\codebuild\tmp\output\src181780091\src\src\Amazon.Lambda.Tools\LambdaUtilities.cs:line 139
   at Amazon.Lambda.Tools.Commands.PackageCICommand.PerformActionAsync() in C:\codebuild\tmp\output\src181780091\src\src\Amazon.Lambda.Tools\Commands\PackageCICommand.cs:line 115
   at Amazon.Common.DotNetCli.Tools.Commands.BaseCommand`1.ExecuteAsync() in C:\codebuild\tmp\output\src181780091\src\src\Amazon.Common.DotNetCli.Tools\Commands\BaseCommand.cs:line 46

Location

https://github.com/aws/aws-extensions-for-dotnet-cli/blob/cdd490450e0407139d49248d94a4a899367e84df/src/Amazon.Lambda.Tools/Commands/PackageCICommand.cs#L120

https://github.com/aws/aws-extensions-for-dotnet-cli/blob/cdd490450e0407139d49248d94a4a899367e84df/src/Amazon.Common.DotNetCli.Tools/Commands/BaseCommand.cs#L435

https://github.com/aws/aws-extensions-for-dotnet-cli/blob/cdd490450e0407139d49248d94a4a899367e84df/src/Amazon.Common.DotNetCli.Tools/Utilities.cs#L230-L248

lukeemery avatar Jan 02 '22 18:01 lukeemery

Reproducible

ashishdhingra avatar Nov 16 '23 21:11 ashishdhingra