Inconsistent email value between gitlab CI env variables and valid values for avatar_url

Summary

I use an email address with an internationalized domain name. This is correcly handled in the gitlab UI and I was able to set this email as my primary email.

When pushing commits to gitlab CI, the CI platforms sets ${GITLAB_USER_EMAIL} to the unicode version (that which is presented to the user), however calling the avatar api with the unicode version fails. The avatar api expects the IDNA encoded version and throws a 400 on the unicode email.

This makes it very difficult to use the API from within a gitlab CI pipeline as a user has to parse the email to extract the domain part, and manually encode that. It would be nice if both APIs could be aligned.

Steps to reproduce

I'm not very keen to put my email address in a publicly searchable issue tracker but I am totally willing to provide examples privately.

  • Create a profile using an email addresss which has an internationalized domain name (IDN)
  • Create a project with a CI pipeline
  • Try to retrieve your avatar using the api from within a CI job : AVATAR_URL=$(curl -s "${CI_API_V4_URL}/avatar?email=${GITLAB_USER_EMAIL}&size=32" | node -e 'console.log(JSON.parse(require("fs").readFileSync(0, "utf8")).avatar_url)')

Example Project

you can witness the issue in the jobs of https://gitlab.com/jeantil/now-gitlab-ci-sample/

What is the current bug behavior?

When using an IDN calling the avatar API with the value provided by gitlab ci in GITLAB_USER_EMAIL results in a 400 error

What is the expected correct behavior?

When using an IDN calling the avatar API with the value provided by gitlab ci in GITLAB_USER_EMAIL results in the avatar url being returned.

Relevant logs and/or screenshots

$ AVATAR_URL=$(curl -s "${CI_API_V4_URL}/avatar?email=${GITLAB_USER_EMAIL}&size=32" | node -e 'console.log(JSON.parse(require("fs").readFileSync(0, "utf8")).avatar_url)')
undefined:1
<!DOCTYPE html>
^

SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at [eval]:1:18
    at Script.runInThisContext (vm.js:122:20)
    at Object.runInThisContext (vm.js:329:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at evalScript (internal/bootstrap/node.js:589:27)
    at startup (internal/bootstrap/node.js:265:9)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

Output of checks

This occurs on gitlab.com

/label ~bug

Edited by Jean Helou