aws / aws/aws-extensions-for-dotnet-cli

JSONPath not fully supported in CLI

Open
#199 1 comment 0 reactions 0 assignees View on GitHub
bug module/cli-ext p2 queued
Dominant language
C#
Stars
393
Forks
90
Avg merge
2d 19m
Merged PRs (30d)
3

Description

### 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

Contributor guide

Open the contributing guide

Research direction

Start with ProcessTemplateSubstitions in src/Amazon.Lambda.Tools/LambdaUtilities.cs, then inspect the substitution handling at the cited locations in PackageCICommand.cs, BaseCommand.cs, and Utilities.cs. Reproduce the issue with the provided dotnet lambda package-ci command and verify that JSONPath filters containing = and ; are passed through and processed successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.