The SDK now checks null, undefined and empty string on API methods required string parameters.
Original Message:
Sent: 06-12-2025 03:56
From: Andrew Watson
Subject: Possible bug in the Javascript SDK
Hi Jerome,
That makes perfect sense.
However, I still think there is a bit of an issue with regard to the SDK function itself - though a small and possibly immaterial issue :-).
The function "getUser(userId, opts)" has a Return type of "User", which is a single object.
The function "getUsers(opts)" has a Return type of "UserEntityListing", which is an array of objects.
If you call "getUser(userId, opts)" with "userId" = "", it will return a "UserEntityListing".
This contradicts the documentation and has the potential to break code.
Surely the function should return an error if a valid (or at least non-empty) "userId" is not provided.
Cheers
Andrew Watson
------------------------------
Andrew Watson
Architect
Original Message:
Sent: 06-11-2025 14:39
From: Jerome Saint-Marc
Subject: Possible bug in the Javascript SDK
Hello,
It is most likely because using an empty userId (empty string) will result in this url: GET /api/v2/users/
Which is the endpoint for user listing (i.e. getUsers).
The SDK only checks if userId is not null and not undefined.
Regards,
------------------------------
Jerome Saint-Marc
Senior Development Support Engineer
Original Message:
Sent: 06-11-2025 12:39
From: Andrew Watson
Subject: Possible bug in the Javascript SDK
Hi,
I think there is a bug in the Javascript "getUser" function (https://mypurecloud.github.io/platform-client-sdk-javascript/UsersApi#getUser).
It is my understanding that the function requires a userId as a parameter and returns a single user entity in the response.
However, if I execute the function with a userId variable set to "", I get all users returned in the response.
I.e.
let userId = "";
// Make request to GET /api/v2/users/{userId}
const usersApi = new m_platformClient.UsersApi();
await usersApi.getUser(userId, {}).then(...
will return an array of all users in the org.
Cheers
Andrew Watson
#PlatformSDK
------------------------------
Andrew Watson
Architect
------------------------------