Issue with "Post Registration Action"

The “Post User Registration” is going to call after user registration but always getting the below error inside monitor → logs

{
  "action_name": " assign-role-hook",
  "response": {
    "exception": {
      "code": 3,
      "error": 3,
      "message": "execution failed: bad status code: 500"
    },
    "stats": {
      "total_request_duration_ms": 219,
      "total_runtime_execution_duration_ms": 216,
      "runtime_processing_duration_ms": 140,
      "action_duration_ms": 6,
      "runtime_external_call_duration_ms": 70,
      "boot_duration_ms": 203,
      "network_duration_ms": 2
    }
  },
  "error": {
    "id": "invalid_argument",
    "msg": "Invalid Argument"
  },
  "started_at": "2023-06-22T07:15:24.352847681Z",
  "ended_at": "2023-06-22T07:15:24.572050658Z"
}

Below are the action flow and code

const axios = require('axios');
exports.onExecutePostUserRegistration = async (event, api) => {
  await axios({
      method: 'POST',
      url: 'https://dumy-url.com/qa/auth0/users',
      timeout: 30000,
      followRedirects: true,
      headers: {
        'x-api-key': 'x-api-key'
      },
      data: event.user
    });
};


Also “Actions Logs BETA” is doesn’t display anything about runtime action logs. Not sure what is going on. Can you someone please look into this ?

Hi @spatidar,

Welcome to the Auth0 Community!

Usually when a bad status code 500 is returned, it means that the URL you are trying to reach has an internal server error.

Have you gotten a chance to test your Action script with the built-in debugger?

Let me also add that I have tried testing your URL in a browser and could not complete the request.

In the meantime, I will check the Action Logs Beta and see if are any issues with it.

Thanks,
Rueben

Hi Rueben,

I didn’t mention the actual url. Also i ran from built-in debugger but getting the same issue. Even for below code getting same error.

const axios = require('axios');
exports.onExecutePostUserRegistration = async (event) => {
  console.log('Shailendra ' + event.user.given_name);
};

One more thing, I removed the imported axios package and it worked but we need it to get token and persist the user into db.

1 Like

Hi @spatidar,

Thanks for the update and clarification.

I have just tested this on my end and reproduced the same error you observed. Specifically, I had to be on either a prod-us or prod-eu tenant using Actions with Node 18 (beta). For some reason, it is preventing me from importing the Axios module.

However, if I create an Action with Node 16, I do not encounter any issues with importing the Axios module.

For the moment, I recommend using Actions with Node 16 runtime while I reach out to our engineers about this problem.

Once this issue is fixed, I will reach out again on this thread with an update.

Thanks,
Rueben

1 Like

Thanks @rueben.tiow , It’s working with Node 16.x

1 Like

Hi @spatidar,

I have just checked with our Engineering team on this and learned that when using Actions with the Node 18 runtime, we must explicitly specify all of our dependencies.

After adding the dependency you should be able to call the Axios module.

Thanks,
Rueben

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.