Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Possible bug in the Javascript SDK

    Posted 06-11-2025 12:40
    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
    ------------------------------


  • 2.  RE: Possible bug in the Javascript SDK

    Posted 06-11-2025 14:40
    Edited by Jerome Saint-Marc 06-11-2025 14:41

    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
    ------------------------------



  • 3.  RE: Possible bug in the Javascript SDK

    Posted 06-12-2025 03:56
    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
    ------------------------------



  • 4.  RE: Possible bug in the Javascript SDK

    Posted 06-23-2025 05:06

    Hello,

    We have made a fix in the last SDK version - Javascript SDK 225.0.0

    The SDK now checks null, undefined and empty string on API methods required string parameters.

    Regards,



    ------------------------------
    Jerome Saint-Marc
    Senior Development Support Engineer
    ------------------------------