Rule : Add persistent attributes to the user gives an ERROR when executed

Getting the error : “ERROR: The user does not exist.” when I am trying to execute the default rule “Add persistent attributes to the user”. No changes to the code provided:

function (user, context, callback) {
  user.user_metadata = user.user_metadata || {};
  user.user_metadata.color = user.user_metadata.color || 'blue';
  context.idToken''] = user.user_metadata.color;

  auth0.users.updateUserMetadata(user.user_id, user.user_metadata)
        callback(null, user, context);

What am I doing wrong? I want to add custom claims to the idToken and accessToken. Tried using the example shown here: OpenID Connect Scopes


const namespace = '';
context.idToken[namespace + 'favorite_color'] = user.favorite_color;

but it does not work. I don’t see the claim getting added to the idToken