Aws-lambda-dotnet: Amazon.Lambda.AspNetCoreServer 3.x Query Encoding Regression

Created on 13 Mar 2019  路  11Comments  路  Source: aws/aws-lambda-dotnet

Hi,

We are seeing a problem when upgrading to the 3.x version of Amazon.Lambda.AspNetCoreServer with regards to query strings needing URL encoding _twice_. Take the following controller:

[Route("health")]
public class HealthController : Controller
{
    public DateTimeOffset Index([FromQuery] DateTimeOffset testDateTimeOffset)
    {
        return testDateTimeOffset;
    }
}

Snippet from CloudFormation template for API gateway configuration:

"/{proxy+}": {
    "x-amazon-apigateway-any-method": {
        "x-amazon-apigateway-integration": {
            "httpMethod": "POST",
            "type": "aws_proxy",
            "uri": { "Fn::Sub": "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ApiLambda.Arn}/invocations" }
        }
    }
}

The request is sent to API Gateway, with an Asp.NET Lambda function behind it set as a proxy resource handling all requests.

| Version | /health?testDateTimeOffset={x} | Response |
|------------------|-------------------------------------------|----------------------------------|
| 3.x | 2019-03-12T16%3A06%3A06.5498170%2B00%3A00 | 0001-01-01T00:00:00+00:00 |
| 2.1.x | 2019-03-12T16%3A06%3A06.5498170%2B00%3A00 | 2019-03-12T16:06:06.549817+00:00 |

If we double encode the query parameter as 2019-03-12T16%253A06%253A06.5498170%252B00%253A00 with the 3.x package, the date time is as parsed correctly: 2019-03-12T16:06:06.549817+00:00.

This seems like incorrect behavior - single encoding should be enough as it was with 2.1.x.

bug

Most helpful comment

I submitted the PR for this fix. https://github.com/aws/aws-lambda-dotnet/pull/451

All 11 comments

Hi @alanedwardes, thank you for reporting this. We have had some similar bug reports; this may be a duplicate. I'll work on getting this prioritized highly.

I haven't had time to make a demo for this issue but we encountered the same problem. We had IdentityServer running in lambda (move to elb now due to performance) and sign-in uses a number of redirects. These redirects broke because of the extra url decoding that is done in v3.x.

I have a repo case and I'm investigating how to fix the issue.

Is there any news on the fix for this issue?

Thanks!

I apologize I haven't gotten to this sooner. The VS 2019 release took more time than I had anticipated. I'll get to this soon.

Thanks Norm - your efforts are appreciated :)

I submitted the PR for this fix. https://github.com/aws/aws-lambda-dotnet/pull/451

Version 3.0.4 is out now with this fix.

Fantastic - I will try to test tomorrow!

Closing as I believe the last version fixed the issue. If there is still a problem feel free to reopen or create a new issue.

Sorry, took a little while to get around to this. The fix looks good, query processing looks to be working fine now!

Was this page helpful?
0 / 5 - 0 ratings