auth0.v3.management.users.Users returns stale data immediately after a successful role update

We’ve discovered a timing-based consistency issue in the Auth0 Management API. When updating a user’s app_metadata via auth0.v3.management.users.Users.update API, an immediately following fetch of users via auth0.v3.management.users.Users.list call often returns the old data. After a short delay (e.g. 1 second), the fetch of users returns the updated user data as expected.

Reproduction Steps:

  1. Update any app_metadata property of a user via auth0.v3.management.users.Users.update
  2. Immediately after the update, fetch all users via auth0.v3.management.users.Users.list
  3. Observe that the returned user object still contains the old data before the update.
  4. Wait ~1 second, then repeat the fetch users request. Observe that the user now has the updated data.

To test this further I created a python script to do the update and get all users in a loop for 20 times and following is what I observed:

  • With no delay between update and fetch users, the fetch requests return stale data for all 20 iterations.
  • After a 1 second delay between update and fetch users, the fetch requests return stale data for 5 iterations and updated data for 15 iterations.
  • After a 3 second delay between update and fetch users, the fetch requests return updated data for all 20 iterations.

I am using auth0-python = "==3.14.0" library in my project.

Questions:

  • Is this an expected propagation delay, and can this be tuned?
  • Are there recommended patterns or headers to force fresh reads?

Hi @harit,

Welcome to the Auth0 Community!

The behavior you have described above is the expected one, since methods such as Users.list are eventually consistent, meaning that it will take some time for all the changes to be visible when inspecting the user object. You can check out this community post on the matter.

So if you want to pursue an approach that is instantly available, i would recommend fetching a Management API Access Tokens and make a call to an endpoint such as the GET /v2/users/{id} or the GET /v2/users-by-email endpoint, which are immediately consistent.

I hope this helps!
Thanks,
Remus