Admin API : "GET /users/:id/emails" is inconsistent w/ documentation

Summary

Admin API : "GET /users/:id/emails" is inconsistent with documentation.

Per documentation,

Get a list of a specified user’s emails. Available only for admin

  • When getting aa email list from @asaba 's ID (2165775), it returns no emails.
  • When getting an email list from @thavisouk 's ID (1877050), it returned a list missing his primary account.

Steps to reproduce

Get Antony's account emails

URL="https://gitlab.com/api/v4/users/2165775/emails"
#GET /users/:id/emails
curl $METHOD  -H 'Content-Type: application/json' \
        -H 'PRIVATE-TOKEN: '$API_KEY \
		$URL 

Get Jim's account emails

URL="https://gitlab.com/api/v4/users/1877050/emails"
#GET /users/:id/emails
curl $METHOD  -H 'Content-Type: application/json' \
        -H 'PRIVATE-TOKEN: '$API_KEY \
		$URL 

What is the current bug behavior?

Not all emails associated with account are listed

What is the expected correct behavior?

List all emails associated with account. Going into the admin console, it will display more emails beyond what is listed through Admin API.

Relevant logs and/or screenshots

Results from asaba ID, only has 1 primary and public address

[]

Results from Jim's ID

[
  {
    "id": 234302,
    "email": "jim@example.com"
  },
  {
    "id": 234311,
    "email": "jim.thavisouk@owasp.org"
  }
]

Output of checks

  • This bug happens on GitLab.com

Results of GitLab environment info

  • Using: Gitlab.com

Possible fixes

  • (If you can, link to the line of code that might be responsible for the problem)
  • Not sure
Edited by Antony Saba