Error decoding lambda response

PLEASE help us help you by writing a good post!

Site Name: https://5edb48143846e0b608a234a0--heuristic-yonath-e84bf6.netlify.app/
DNS issues? Seems not to be a DNS issue since the live preview already not working. But here anyway the link to my custom domain: https://www.wiegandautomobile.de/
Build problems? Build goes through. Site is live. Cannot see any error.

The message appears whenever calling the site.

error decoding lambda response: error decoding lambda response: json: cannot unmarshal number into Go struct field APIGatewayProxyResponse.multiValueHeaders of type string

The page was running smothly the last 7 days with no issues and changes made. Now one of a sudden, this message appears yesterday night.

The page is a React Next.js application.

Please help. It is live already. My customers getting angry :frowning:

1 Like

Same here, also with an Next.js application. Didn’t made any changes and now getting the same error. Seem especially happing with server side rendered pages which receives data from the api. Pages without data connection are working well. On localhost everything works well.

We are facing the same error last 2 days. I noticed other posts in this forum facing the same issue in the past 2 days.

These errors are both in how you return values from your lamdba. We did recently add some better support for multivalue headers that might have changed things, but as of today, everything - header, body, etc, needs to be JSON.stringify()'d like this:

When you don’t do that for something that is being returned from your lambda, you’ll receive errors like the above.

Not thrilled about the breaking change, but noted, thanks.

It might be worth updating the documentation, as this causes the hello world example in the docs to fail:

exports.handler = function(event, context, callback) {
    callback(null, {
    statusCode: 200,
    body: "Hello, World"
    });
}
1 Like

hey @legionfilms, thanks for pointing this out. We will take a look!

To anyone who has a problem with next js on netlify: https://github.com/FinnWoelm/next-on-netlify/issues/9#issuecomment-637761007
This fixed it for me.

1 Like

Hi @FollowJack, around that time, we did add support for multiValueHeaders in Lambda Function response. That link you mentioned looks to have addressed the change. I’d be interested to hear the experience of the others that reported this issue and if that update mentioned also fixed their issue.

I’m trying to use multiValueHeaders in Netlify function response to set multiple cookies. It works locally with Netlify dev but not when deployed. Any ideas?

I ended up having some values in the multiValueHeaders property that did not have multiple values lol Guess that was a problem. I’m setting multiple cookies like this.

return {
        statusCode: 302,
        headers: {
            Location: `${process.env.APP_DOMAIN}`,
            'Cache-Control': 'no-cache',
        },
        multiValueHeaders: {
            'Set-Cookie': [netlifyCookie, auth0LoginCookie],
        },
        body: JSON.stringify({ msg: `you're good` }),
    };
1 Like

Hey @jamesqquick, thanks for coming back to report your fix!