Duplicated IDs on user API request

Jump to solution
ChrisDev
Community Member

We are making API requests to fetch a list of all users on a Canvas site. To ensure that we are able to keep the users in sync we are planning to use the id field as a unique identifier, unfortunately, we have found that about 6.5k users (about 4% of all users) have a duplicated ID. We are using the "id" field, and this is the endpoint we are hitting: /api/v1/accounts/:account_id/users

Any idea why the ID field is not unique?

What user field should we use to ensure we get a unique ID for each user?

Thanks!

0 Likes
1 Solution
ChrisDev
Community Member

This issue turned out to be due to some Canvas user IDs being larger than the max safe integer size. When our NodeJS code was converting these larges numbers into Node integers it was converting odd numbers into even numbers, so 1001 and 1000 both become 1000 (of course the real numbers were much larger), and thus we had duplicated IDs. The solution was to use a JSON package that converts large numbers into strings. We used the json-bigint to accomplish this and the issue is now resolved.

Thanks to Connor with Canvas support for pointing this out to us.

View solution in original post

0 Likes