Overview
This article explains why the payload validation error occurs when updating or creating a user profile and using undefined
as a value in the app_metadata
or user_metadata
.
For example, when using the following API call:
api.user.setAppMetadata('some-value', undefined).
The resulting error message typically includes:
{
...
"type": "f",
"user update failed: Payload validation error: 'None of the valid schemas were met'. Inner errors: [ ... Payload validation error: 'Missing required property: app_metadata' ... ]"
...
}
Applies To
- Metadata
- Payload Validation
Cause
According to the official Auth0 documentation Metadata data types, app_metadata
supports all JSON data types.
- The JSON specification does not include
undefined
as a valid type. - This value can be specified as a programming language primitive value. For example, in JavaScript-specific primitive, but it is not valid JSON.
- Sending
undefined
in a Rule, Action, or API call will result in a validation failure.
Solution
To avoid validation errors, use null
instead of undefined
, as shown in the example below:
api.user.setAppMetadata(‘some-value’, null);