Skip to content

User email cannot be removed even when optional #844

@ZhugeSong

Description

@ZhugeSong

Checklist

  • I have looked into the Readme and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

We've set up a database connection with optional emails using the Flexible Identifiers and Attributes features. When using the .NET SDK to try to remove a user's email, I haven't been able to get it to work correctly.

When using the API directly, you can set the email property to null, which will cause the field to be removed from the user. However, when we call the .NET SDK and set the Email property to null, that causes the SDK to omit the property from the request, which results in the field being unchanged on the user.

We alternatively tried setting the Email property to the empty string "", but that resulted in an error.

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "Payload validation error: 'Object didn't pass validation for format email: ' on property email (Email address of this user).",
  "errorCode": "invalid_body"
}

I do not necessarily want to change the behavior of sending null using the SDK since "leaving a property unchanged" is a useful feature to support patching an existing user. However, with null being used for that purpose and the empty string producing an error from the API, I am not sure how you should remove a user's email.

Reproduction

  1. Create a database connection
  2. Make email optional for users
  3. Create a user on that connection with some email
  4. Set up a .NET project using the Auth0 .NET SDK
  5. Use the SDK to make a user update request with Email set to null
  6. Observe email is unchanged (reasonable result, but means I cannot remove the email)

Additional context

No response

auth0.net version

7.39.0

.NET version

8

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis points to a verified bug in the code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions