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ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ