ProjectFeaturesCompatibility broken for private projects
Summary
ProjectFeaturesCompatibility always sets ProjectFeature::ENABLED (value 20) if a feature is set to true via the API (e.g. builds_enabled). This does not work for private projects, where visibility_level has the value 0, because in ProjectFeature there is a check that the feature access level cannot be higher than the project access level.
Steps to reproduce
- Create a private project with builds disabled
- Update the project via the API with builds_enabled: True
Expected behavior
The API should not raise an error but enable the corresponding feature insted
Actual behavior
The API responds with an HTTP 400 telling you that the builds_access_level cannot be higher than the repositories access level.
Relevant logs and/or screenshots
API output
{
'project_feature.builds_access_level': [
'cannot have higher visibility level than repository access level'
]
}
Results of GitLab application Check
Checking GitLab Shell ...
GitLab Shell version >= 4.1.1 ? ... OK (4.1.1)
Repo base directory exists?
default... yes
Repo storage directories are symlinks?
default... no
Repo paths owned by git:git?
default... yes
Repo paths access is drwxrws---?
default... yes
hooks directories in repos are links: ...
8/16 ... ok
8/17 ... ok
8/18 ... ok
14/19 ... ok
14/20 ... repository is empty
8/22 ... ok
8/23 ... repository is empty
8/24 ... ok
14/25 ... repository is empty
8/26 ... ok
8/27 ... ok
8/28 ... ok
8/29 ... ok
19/30 ... ok
8/33 ... ok
22/34 ... ok
8/36 ... ok
14/37 ... ok
14/38 ... ok
8/39 ... ok
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK
Send ping to redis server: OK
gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes
Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Reply by email ...
Reply by email is disabled in config/gitlab.yml
Checking Reply by email ... Finished
Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
Git configured with autocrlf=input? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory setup correctly? ... yes
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
projects have namespace: ...
8/16 ... yes
8/17 ... yes
8/18 ... yes
14/19 ... yes
14/20 ... yes
8/22 ... yes
8/23 ... yes
8/24 ... yes
14/25 ... yes
8/26 ... yes
8/27 ... yes
8/28 ... yes
8/29 ... yes
19/30 ... yes
8/33 ... yes
22/34 ... yes
8/36 ... yes
14/37 ... yes
14/38 ... yes
8/39 ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.1.0 ? ... yes (2.3.3)
Your git bin path is "/opt/gitlab/embedded/bin/git"
Git version >= 2.7.3 ? ... yes (2.10.2)
Active users: 4
Checking GitLab ... Finished
Results of GitLab environment info
System information
System:
Current User: git
Using RVM: no
Ruby Version: 2.3.3p222
Gem Version: 2.6.6
Bundler Version:1.13.7
Rake Version: 10.5.0
Sidekiq Version:4.2.7
GitLab information
Version: 8.16.2
Revision: 8829bf1
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: postgresql
URL: https://***
HTTP Clone URL: https://***/some-group/some-project.git
SSH Clone URL: git@***:some-group/some-project.git
Using LDAP: no
Using Omniauth: no
GitLab Shell
Version: 4.1.1
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks/
Git: /opt/gitlab/embedded/bin/git
Possible fixes
https://github.com/gitlabhq/gitlabhq/blob/master/app/models/project_feature.rb#L75