Bug report - identity-signup function runs but no longer updates app_metadata

I’ve been using Netlify Identity for several years now with no issues with the identity-signup function. Sometime in the past two days, I noticed that my identity-signup function is no longer updating the users app_metadata field.

The function executes without failing, but it does not update the users app_metadata.

This issue seems very similar to what @Shadowmap is experiencing here: Identity-signup seems to run successfully, but roles aren't set afterwards

Netlify Site Name: syncmyworkout

Hi, can you provide a reproduction of this issue in the form of your entire code.

I cut a bunch of logic out but this should still reproduce the issue.

exports.handler = async function (event, context) {
  const callbackHeaders = {
    "Access-Control-Allow-Origin": "*",
    "Access-Control-Allow-Headers": "Content-Type, Authorization",
  }

  console.log(`New signup! ${event.body}`)
  const eventBody = JSON.parse(event.body)
  const email = eventBody.user.email
  const name = eventBody.user.user_metadata.full_name || ""

  let callbackBody = JSON.stringify({
    app_metadata: {
      testMetadata: "testMetadata",
    },
  })

  return {
    statusCode: 200,
    headers: callbackHeaders,
    body: callbackBody,
  }
}

@SamO this is a breaking bug for my site. I tried to force update the app_metadata within the identity-signup function (instead of relying on netlify to handle it based on the return body), but the function doesn’t have the needed context to update the user’s app_metadata.

If you have any workarounds you can think of please let me know!

this was a bit hacky, but as a workaround I now call a separate lambda function as soon as the user lands on the account settings page to update their app_metadata.

Hi @teakwood,

This has been escalated to the devs.

I seem to have the same issue. Between April 12th and April 20th this stopped working out of the blue.

Hi, @teakwood and @fabianhijlkema. The fix for this has been rolled out. Would you please test your identity sign-up functions again now? No new deploy is required. They should just be working now.

However, if they are not or if there are any questions, please let us know.

@luke It seems to be working again from our side. Did this involve any changes to the identity-login-background function/hook as well? Because this now is causing a login error (malformed JSON response I believe). While this worked fine until this point.

I’m not sure if I follow what you’re saying, @fabianhijlkema. Could you try to rephrase it or explain the issue in more detail?

Well I’m not sure how to phrase it differently. Before the issue above arose and was fixed by Netlify, our login setup was working fine. After the fix, our background function for identity-login started to error out, resulting in not being able to login at all while the background function was active.

So I was wondering if the fix you’ve deployed also had any impact on this background function? Or that is a mere coincidence and this is a completely separate issue? I haven’t had time to find out exactly what is going wrong with this background function, but it was giving back something like a ‘malformed JSON response’ error.

@hrishikesh Any details on my question?

I’ve created a test with a login background function that is just a basic response…

identity-login-background.js

const handler = async (event, context) => {
	return {
		statusCode: 200,
		body: JSON.stringify({ message: 'Hello World' })
	}
}

module.exports = {
	handler
}

Response given at the GoTrue playground website after trying to login

{"name":"n","status":500,"json":{"code":500,"msg":"Webhook returned malformed JSON: EOF","error_id":"1735973f-5bfb-4a1c-96b1-d2e204b6429d"}}

Has something changed that I’ve missed?

When I remove the background function, logging in works as expected.

As far as I’m aware, webhooks are only supposed to send user data as the response, are you sure sending a message hello world actually works?