Lambda response is ignored when using Function URL (.NET)

0

I've run into an issue where my .NET AWS Lambda function handler, which is set up to be accessible via the Lambda Function URL feature rather than API Gateway, is ignoring the APIGatewayHttpApiV2ProxyResponse I'm returning. It always responds with the original request body and the Content-Type header value of application/json.

I have exactly one line of code that can possibly write to the log in this function handler, followed by a straightforward response, not throwing any exceptions or anything:

var result = JsonConvert.DeserializeObject<DncInResponse>(responseString);
if (!result.success) LambdaLogger.Log("DNC callback failed: " + result.message);

return new APIGatewayHttpApiV2ProxyResponse() { Body = responseString, Headers = new Dictionary<string, string> { { "content-type", "text/xml" } }, StatusCode = 200, IsBase64Encoded = false };

(Putting aside the fact that I'm returning text/xml at the moment for what should be a JSON response... I tried several different response bodies, content types that match the body, and also capitalized Content-Type.)

My DNC callback failed message appears in CloudWatch when I send a POST or GET request to the appropriate URL, so it's definitely executing the function handler up to the return statement.

I tried it with [assembly: LambdaSerializer(DefaultLambdaJsonSerializer)], [assembly: LambdaSerializer(Amazon.Lambda.Serialization.Json.JsonSerializer)] as it's done here (except with APIGatewayHttpApiV2ProxyResponse as the response type) and with SourceGeneratorLambdaJsonSerializer and the partial class and attributes as described here. I'm also using the latest version of every included NuGet package.

dpmm
已提问 9 个月前395 查看次数
1 回答
0

I translated this lambda function line-for-line to JavaScript, and it works fine. I really want to say this is a bug in the AWS SDK for .NET or whatever's behind that, but I'd be surprised if nobody else ran into it until now.

The JavaScript version of the return value:

    return {
        statusCode: 200,
        headers: {"content-type": "text/xml"},
        body: "<a bunch of irrelevant XML>",
    };
dpmm
已回答 9 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则