Skip to content

users.info endpoint: Cannot read property 'username' of undefined #16491

@nullbio

Description

@nullbio

Description:

When attempting to call users.info endpoint using

GET http://rocketchat:4000/api/v1/users.info?username=bob`
X-Auth-Token: mOwTQmt_UpOG8HWH_VQCMYyxvLEy_BTnPo6Wpv3zVW2 
X-User-Id: 9dgf7Kend5guGWPdD

Error response (http 400):

{"success":false,"error":"Cannot read property 'username' of undefined"}

Steps to reproduce:

  1. Start rocket chat docker image with mongodb
  2. Curl the users.info endpoint with a non-existing user in the username field

Expected behavior:

A http response with a more normal error message. Something similar to results of calling with a userId instead of a username:

{"success":false,"error":"Failed to get the user data for the userId of \"9dgf7Kend5guGWPdD\"."}

Actual behavior:

Looks like an internal server error but also returns http 400:

{"success":false,"error":"Cannot read property 'username' of undefined"}

Server Setup Information:

  • Version of Rocket.Chat Server: 2.4.1, 2.4.7, 3.0.0-rc.2
  • Operating System: Ubuntu 18.04
  • Deployment Method: Docker
  • Number of Running Instances: 1
  • MongoDB Version: 4.0

Client Setup Information

  • Desktop App or Browser Version: cURL
  • Operating System: Ubuntu 18.04

Relevant logs:

rocketchat_1          | API ➔ debug get users.info threw an error: TypeError: Cannot read property 'username' of undefined
rocketchat_1          |     at getFullUserData (app/lib/server/functions/getFullUserData.js:106:58)
rocketchat_1          |     at Object.get (app/api/server/v1/users.js:166:6)
rocketchat_1          |     at app/api/server/api.js:343:82
rocketchat_1          |     at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
rocketchat_1          |     at Object._internalRouteActionHandler [as action] (app/api/server/api.js:343:39)
rocketchat_1          |     at Route.share.Route.Route._callEndpoint (packages/nimble_restivus/lib/route.coffee:150:32)
rocketchat_1          |     at packages/nimble_restivus/lib/route.coffee:59:33
rocketchat_1          |     at packages/simple_json-routes.js:98:9
rocketchat_1          | API ➔ debug Failure {
rocketchat_1          |   statusCode: 400,
rocketchat_1          |   body: {
rocketchat_1          |     success: false,
rocketchat_1          |     error: "Cannot read property 'username' of undefined",
rocketchat_1          |     stack: undefined
rocketchat_1          |   }
rocketchat_1          | }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions