400 error on merge request approval API POST endpoint for free subscription
Summary
From GitLab v15.2.0+, on a free subscription, making a POST API call to the endpoint POST /projects/:id/approval_rules
results in a 400 status code and an empty message response ({"message":{}}
).
The endpoint is available for premium and ultimate subscription and will not work for free subscription but the message output can be misleading for users attempting to test out these versions.
This came up in a zendesk ticket - internal only
What is the current bug behavior?
Empty error message when on free subscription when attempting to make a POST request on POST /projects/:id/approval_rules
endpoint
What is the expected correct behavior?
If not on premium or ultimate subscription, a clear error message should be displayed.
Relevant logs and/or screenshots
# curl --request POST --header "Content-Type: application/json" --header "private-token: xxxxxxxxxx" \
--data '{"approvals_required": 1, "name": "approval1", "rule_type": "regular"}' \
--url "https://gitlab.example.com/api/v4/projects/1/approval_rules" -i
HTTP/1.1 400 Bad Request
Server: nginx
Date: Thu, 23 Mar 2023 10:42:28 GMT
Content-Type: application/json
Content-Length: 14
Connection: keep-alive
Cache-Control: no-cache
Vary: Origin
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Request-Id: 01GW71062V8W5KCFJ7ATQ9TQEG
X-Runtime: 0.070806
{"message":{}}
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
# gitlab-rake gitlab:env:info System information System: Proxy: no Current User: git Using RVM: no Ruby Version: 3.0.5p211 Gem Version: 3.2.33 Bundler Version:2.3.15 Rake Version: 13.0.6 Redis Version: 6.2.8 Sidekiq Version:6.5.7 Go Version: unknown GitLab information Version: 15.10.0-ee Revision: defe6e7f882 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 13.8 URL: https://basic-instance-cmutua.env-632302eb.gcp.gitlabsandbox.net HTTP Clone URL: https://basic-instance-cmutua.env-632302eb.gcp.gitlabsandbox.net/some-group/some-project.git SSH Clone URL: git@basic-instance-cmutua.env-632302eb.gcp.gitlabsandbox.net:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 14.18.0 Repository storages: - default: unix:/var/opt/gitlab/gitaly/gitaly.socket GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Results of GitLab application Check
Expand for output related to the GitLab application check
#sudo gitlab-rake gitlab:check SANITIZE=true
Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 14.18.0 ? ... OK (14.18.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 (cluster/worker) ... 1/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 ...
Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Cable config exists? ... yes Resque config exists? ... 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) Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units) Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units) Projects have namespace: ... 2/1 ... yes Redis version >= 6.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (3.0.5) 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 7.x-8.x or OpenSearch version 1.x ... skipped (Advanced Search is disabled) All migrations must be finished before doing a major upgrade ... skipped (Advanced Search is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished