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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠