Error decoding lambda response

PLEASE help us help you by writing a good post!

Site Name:
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:
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:


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.

1 Like

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:
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` }),

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

I have this problem but I’m using graphql and I need help. Please check the code below

`exports.handler = async function handler(event, context) {
try {
await connectToMongoDB();

const typeDefs = getTypeDefs(gql);
const resolvers = getResolvers;

const server = new ApolloServer({
  context: () => ({
    models: {

return new Promise((yay, nay) => {
  const cb = (err, args) => (err ? nay(err) : yay(args));
    cors: {
      origin: '*',
  })(event, context, cb);

} catch (error) {
console.error(‘Error al conectarse con BD’, error);

return false;

How can I apply JSON.stringify?

This code looks very familiar! Which makes me think that you’re seeing the same error as the OP but for a different reason. We worked through something similar over here:

Want to check out that thread and let us know if it helps you resolve the issue?

1 Like

Hello Jen,
I have no node_modules in my lambda folder (like the topic tha you sent me to check). I use just one package.json and it is in the project root.
Works fine in local but Netlify throws a 502 error. I still need to run npm i inside my lambda folder?

Depends entirely on how you send the function - which of these 3 methods would you be trying to use?

2/3 of them would not require you to do that :slight_smile:

Hello! Thanks for your answer.
I use the netlify-lambda to build the bundle that I need.

1 Like