User’s Full name (`name`) field does not have a length limit

Summary

The User model only validates the presence of a full name, but not its maximum length.

Steps to reproduce

Set your full name to very long name.

Example Project

N/A

What is the current bug behavior?

  • On a fresh gitlab-ce setup, I can set a very long name up to 8191 bytes. After which, attempt to change the name will result in 500 Error:

    PG::ProgramLimitExceeded: ERROR:  index row requires 9048 bytes, maximum size is 8191
  • On GitLab.com, the limit is 512 bytes.

What is the expected correct behavior?

  • An overly long name should be rejected, or there should be ways to deal with long names, e.g. using CSS ellipsis and/or length truncation.
  • Let's use a maximum name length of 128 characters.

Relevant logs and/or screenshots

  • In some cases, the text overflows to the right side of the screen.

    image

  • In other cases, the text gets hard-wrapped to the next line.

    image

  • Sometimes, both happens:

    image

  • Text ellipsis is applied, preventing layout from breaking in this case:

    image

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:env:info)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

https://gitlab.com/gitlab-org/gitlab-ce/blob/5b23f2b016f4e5d33387d7474148d2a59b213ee6/app/models/user.rb#L162

Edited by Jeremy Watson (ex-GitLab)