Project can have a negative STAR count resulting in Project settings being unchangeable
Summary
Through some unknown process, an ReachLarge GitLab Premium customer found that they had projects whose settings could not be updated.
When attempting to change the affected projects settings, the error message Star count must be greater than or equal to 0
will be shown.
Steps to reproduce
We don't know how or what caused the STAR numbers to be different from the number of users that have actually STARRED the project.
Manually setting the Star count to a negative value will allow this to be replicated, for example in gitlab-psql
:
Update projects set star_count=-1 where id=<ID_of_test_project>;
What is the current bug behavior?
It is possible to have projects with a STAR count less than zero.
What is the expected correct behavior?
It should not be possible to have a project with STAR count less than zero.
Relevant logs and/or screenshots
Workaround
For a project that throws this error message, ask a few people to STAR it until the count reaches 0 or higher.
Possible fixes
We discussed this in Support team session.
@anton and @tmike performed a code investigation.
They showed that this line of code allows .update_counters
to skip validation.