Projects API query order_by=repository_size 400 Bad Request
Summary
Initially reported in ZD (internal use only). When querying Projects API to list all projects and order them by repository_size you receive 400 bad request, tested on GitLab 12.10.7-ee and up until 13.1.6-ee.
13.2.4-ee doesn't seem to have this issue.
Steps to reproduce
- Spin up an instance with 12.10.7-ee or 13.1.6-ee.
- Add your license.
- Add 2 sample projects.
- Create a personal token with API access.
- Call projects API with
order_by=repository_size
Example Project
This does not happen in gitlab.com
What is the current bug behavior?
Query request returns error message:
{"error":"order_by does not have a valid value"}
What is the expected correct behavior?
Query request returns an array of projects:
[{"id":1,"description":"","name":"P1","name_with_namespace":"Administrator / P1","path":"p1","path_with_namespace":"root/p1","created_at":"2020-08-14T11:05:31.265Z","default_branch":"master","tag_list":[],"ssh_url_to_repo":"git@14c4ed7e74bd:root/p1.git","http_url_to_repo":"http://14c4ed7e74bd/root/p1.git","web_url":"http://14c4ed7e74bd/root/p1","readme_url":"http://14c4ed7e74bd/root/p1/-/blob/master/README.md","avatar_url":null,"forks_count":0,"star_count":0,"last_activity_at":"2020-08-14T11:05:31.265Z","namespace":{"id":1,"name":"Administrator","path":"root","kind":"user","full_path":"root","parent_id":null,"avatar_url":"https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon","web_url":"http://14c4ed7e74bd/root"},"_links":{"self":"http://14c4ed7e74bd/api/v4/projects/1","issues":"http://14c4ed7e74bd/api/v4/projects/1/issues","merge_requests":"http://14c4ed7e74bd/api/v4/projects/1/merge_requests","repo_branches":"http://14c4ed7e74bd/api/v4/projects/1/repository/branches","labels":"http://14c4ed7e74bd/api/v4/projects/1/labels","events":"http://14c4ed7e74bd/api/v4/projects/1/events","members":"http://14c4ed7e74bd/api/v4/projects/1/members"},"empty_repo":false,"archived":false,"visibility":"private","owner":{"id":1,"name":"Administrator","username":"root","state":"active","avatar_url":"https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon","web_url":"http://14c4ed7e74bd/root"},"resolve_outdated_diff_discussions":false,"container_registry_enabled":true,"container_expiration_policy":{"cadence":"1d","enabled":true,"keep_n":10,"older_than":"90d","name_regex":null,"name_regex_keep":null,"next_run_at":"2020-08-15T11:05:31.338Z"},"issues_enabled":true,"merge_requests_enabled":true,"wiki_enabled":true,"jobs_enabled":true,"snippets_enabled":true,"service_desk_enabled":false,"service_desk_address":null,"can_create_merge_request_in":true,"issues_access_level":"enabled","repository_access_level":"enabled","merge_requests_access_level":"enabled","forking_access_level":"enabled","wiki_access_level":"enabled","builds_access_level":"enabled","snippets_access_level":"enabled","pages_access_level":"private","emails_disabled":null,"shared_runners_enabled":true,"lfs_enabled":true,"creator_id":1,"import_status":"none","open_issues_count":0,"ci_default_git_depth":50,"public_jobs":true,"build_timeout":3600,"auto_cancel_pending_pipelines":"enabled","build_coverage_regex":null,"ci_config_path":null,"shared_with_groups":[],"only_allow_merge_if_pipeline_succeeds":false,"allow_merge_on_skipped_pipeline":null,"request_access_enabled":true,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":true,"printing_merge_request_link_enabled":true,"merge_method":"merge","suggestion_commit_message":null,"auto_devops_enabled":true,"auto_devops_deploy_strategy":"continuous","autoclose_referenced_issues":true,"repository_storage":"default","approvals_before_merge":0,"mirror":false,"external_authorization_classification_label":null,"packages_enabled":true,"marked_for_deletion_at":null,"marked_for_deletion_on":null,"compliance_frameworks":[],"permissions":{"project_access":{"access_level":40,"notification_level":3},"group_access":null}},{"id":2,"description":"","name":"P2","name_with_namespace":"Administrator / P2","path":"p2","path_with_namespace":"root/p2","created_at":"2020-08-14T11:05:43.970Z","default_branch":null,"tag_list":[],"ssh_url_to_repo":"git@14c4ed7e74bd:root/p2.git","http_url_to_repo":"http://14c4ed7e74bd/root/p2.git","web_url":"http://14c4ed7e74bd/root/p2","readme_url":null,"avatar_url":null,"forks_count":0,"star_count":0,"last_activity_at":"2020-08-14T11:05:43.970Z","namespace":{"id":1,"name":"Administrator","path":"root","kind":"user","full_path":"root","parent_id":null,"avatar_url":"https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon","web_url":"http://14c4ed7e74bd/root"},"_links":{"self":"http://14c4ed7e74bd/api/v4/projects/2","issues":"http://14c4ed7e74bd/api/v4/projects/2/issues","merge_requests":"http://14c4ed7e74bd/api/v4/projects/2/merge_requests","repo_branches":"http://14c4ed7e74bd/api/v4/projects/2/repository/branches","labels":"http://14c4ed7e74bd/api/v4/projects/2/labels","events":"http://14c4ed7e74bd/api/v4/projects/2/events","members":"http://14c4ed7e74bd/api/v4/projects/2/members"},"empty_repo":true,"archived":false,"visibility":"private","owner":{"id":1,"name":"Administrator","username":"root","state":"active","avatar_url":"https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80\u0026d=identicon","web_url":"http://14c4ed7e74bd/root"},"resolve_outdated_diff_discussions":false,"container_registry_enabled":true,"container_expiration_policy":{"cadence":"1d","enabled":true,"keep_n":10,"older_than":"90d","name_regex":null,"name_regex_keep":null,"next_run_at":"2020-08-15T11:05:43.987Z"},"issues_enabled":true,"merge_requests_enabled":true,"wiki_enabled":true,"jobs_enabled":true,"snippets_enabled":true,"service_desk_enabled":false,"service_desk_address":null,"can_create_merge_request_in":true,"issues_access_level":"enabled","repository_access_level":"enabled","merge_requests_access_level":"enabled","forking_access_level":"enabled","wiki_access_level":"enabled","builds_access_level":"enabled","snippets_access_level":"enabled","pages_access_level":"private","emails_disabled":null,"shared_runners_enabled":true,"lfs_enabled":true,"creator_id":1,"import_status":"none","open_issues_count":0,"ci_default_git_depth":50,"public_jobs":true,"build_timeout":3600,"auto_cancel_pending_pipelines":"enabled","build_coverage_regex":null,"ci_config_path":null,"shared_with_groups":[],"only_allow_merge_if_pipeline_succeeds":false,"allow_merge_on_skipped_pipeline":null,"request_access_enabled":true,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":true,"printing_merge_request_link_enabled":true,"merge_method":"merge","suggestion_commit_message":null,"auto_devops_enabled":true,"auto_devops_deploy_strategy":"continuous","autoclose_referenced_issues":true,"repository_storage":"default","approvals_before_merge":0,"mirror":false,"external_authorization_classification_label":null,"packages_enabled":true,"marked_for_deletion_at":null,"marked_for_deletion_on":null,"compliance_frameworks":[],"permissions":{"project_access":{"access_level":40,"notification_level":3},"group_access":null}}]
Relevant logs and/or screenshots
{"error":"order_by does not have a valid value"}
Output of checks
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`) # gitlab-rake gitlab:env:info System information System: Proxy: no Current User: git Using RVM: no Ruby Version: 2.6.6p146 Gem Version: 2.7.10 Bundler Version:1.17.3 Rake Version: 12.3.3 Redis Version: 5.0.9 Git Version: 2.27.0 Sidekiq Version:5.2.7 Go Version: unknown GitLab information Version: 13.1.6-ee Revision: 3795509594b Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 11.7 URL: http://4ae59def3259 HTTP Clone URL: http://4ae59def3259/some-group/some-project.git SSH Clone URL: git@4ae59def3259:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 13.3.0 Repository storage paths: - default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Git: /opt/gitlab/embedded/bin/git
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)
gitlab-rake gitlab:env:info
System information System: Proxy: no Current User: git Using RVM: no Ruby Version: 2.6.6p146 Gem Version: 2.7.10 Bundler Version:1.17.3 Rake Version: 12.3.3 Redis Version: 5.0.9 Git Version: 2.27.0 Sidekiq Version:5.2.7 Go Version: unknown
GitLab information Version: 13.1.6-ee Revision: 3795509594b Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 11.7 URL: http://4ae59def3259 HTTP Clone URL: http://4ae59def3259/some-group/some-project.git SSH Clone URL: git@4ae59def3259:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers:
GitLab Shell Version: 13.3.0 Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Git: /opt/gitlab/embedded/bin/git root@4ae59def3259:/# gitlab-rake gitlab:check Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 13.3.0 ? ... OK (13.3.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab App ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet) 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: ... Administrator / P1 ... yes Administrator / P2 ... yes Administrator / P3 ... yes Redis version >= 4.0.0? ... yes Ruby version >= 2.5.3 ? ... yes (2.6.6) Git version >= 2.22.0 ? ... yes (2.27.0) Git user has default SSH configuration? ... yes Active users: ... 1 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
Upgrade to latest GitLab version 13.2.4-ee.