Skip to content

Block user API call on system / internal users results in 500 error

Summary

Trying to block internal internal users like GitLab Support Bot, GitLab Alert Bot and Ghost User via the API returns HTTP 500 Internal Server Error with response body

{"message":"Notification email can't be blank. Notification email is invalid"}

The call failing is correct behaviour, the response is not.

Steps to reproduce

On one of the internal users' id (GitLab Support Bot, GitLab Alert Bot or Ghost User) call

curl -v -X POST --header "PRIVATE-TOKEN: $GITLAB_TOKEN" "http://gitlab.local/api/v4/users/$USER_ID/block"

What is the current bug behavior?

API returns 500 Internal Server Error with message Notification email can't be blank. Notification email is invalid.

What is the expected correct behavior?

API returns 403 Forbidden

Relevant logs and/or screenshots

curl -v -X POST --header "PRIVATE-TOKEN: $GIT_TOKEN" "http://gitlab.local/api/v4/users/25/block"
*   Trying 192.168.56.101...
* TCP_NODELAY set
* Connected to gitlab.local (192.168.56.101) port 80 (#0)
> POST /api/v4/users/25/block HTTP/1.1
> Host: gitlab.local
> User-Agent: curl/7.54.0
> Accept: */*
> PRIVATE-TOKEN: xxx
>
< HTTP/1.1 500 Internal Server Error
< Server: nginx
< Date: Wed, 16 Sep 2020 15:26:53 GMT
< Content-Type: application/json
< Content-Length: 78
< Connection: keep-alive
< Cache-Control: no-cache
< Vary: Origin
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-Request-Id: 9jvH4z9rne6
< X-Runtime: 0.091856
<
* Connection #0 to host gitlab.local left intact
{"message":"Notification email can't be blank. Notification email is invalid"}%

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info
System information
System:		Ubuntu 18.04
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.9
Go Version:	unknown

GitLab information
Version:	13.2.4-ee
Revision:	5f3e8be35c3
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	11.7
URL:		http://gitlab.local
HTTP Clone URL:	http://gitlab.local/some-group/some-project.git
SSH Clone URL:	git@gitlab.local:some-group/some-project.git
Elasticsearch:	no
Geo:		no
Using LDAP:	yes
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
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: ... Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) User output sanitized. Found 4 users of 100 limit.

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? ... 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: ... 2/1 ... yes 1/4 ... yes 26/5 ... yes 33/6 ... yes 34/7 ... yes 33/8 ... yes 36/10 ... yes 36/11 ... yes 36/12 ... yes 1/13 ... yes 41/14 ... yes 41/15 ... yes 41/16 ... yes 41/17 ... yes 46/18 ... yes 46/19 ... yes 48/20 ... yes 48/21 ... yes 35/22 ... yes 48/23 ... yes 53/24 ... yes 55/25 ... yes 2/26 ... yes 29/27 ... yes 52/28 ... yes 2/29 ... yes 2/30 ... yes 2/31 ... yes 60/32 ... yes 60/33 ... yes 60/34 ... yes 60/35 ... yes 60/36 ... yes 60/37 ... yes 60/38 ... yes 60/39 ... yes 60/40 ... yes 60/41 ... yes 60/42 ... yes 60/43 ... yes 60/44 ... yes 60/45 ... yes 60/46 ... yes 60/47 ... yes 60/48 ... yes 60/49 ... yes 60/50 ... yes 60/51 ... yes 60/52 ... yes 60/53 ... yes 60/54 ... yes 60/55 ... yes 60/56 ... yes 60/57 ... yes 60/58 ... yes 60/59 ... yes 60/60 ... yes 60/61 ... yes 60/62 ... yes 60/63 ... yes 60/64 ... yes 60/65 ... yes 60/66 ... yes 60/67 ... yes 60/68 ... yes 60/69 ... yes 60/70 ... yes 60/71 ... yes 60/72 ... yes 60/73 ... yes 60/74 ... yes 60/75 ... yes 60/76 ... yes 60/77 ... yes 60/78 ... yes 60/79 ... yes 60/80 ... yes 60/81 ... yes 60/82 ... yes 60/83 ... yes 60/84 ... yes 60/85 ... yes 60/86 ... yes 60/87 ... yes 60/88 ... yes 60/89 ... yes 60/90 ... yes 60/91 ... yes 60/92 ... yes 60/93 ... yes 60/94 ... yes 60/95 ... yes 60/96 ... yes 60/97 ... yes 60/98 ... yes 60/99 ... yes 60/100 ... yes 60/101 ... yes 60/102 ... yes 60/103 ... yes 60/104 ... yes 60/105 ... yes 60/106 ... yes 60/107 ... yes 60/108 ... yes 60/109 ... yes 60/110 ... yes 60/111 ... yes 60/112 ... yes 60/113 ... yes 60/114 ... yes 60/115 ... yes 60/116 ... yes 60/117 ... yes 60/118 ... yes 60/119 ... yes 60/120 ... yes 60/121 ... yes 60/122 ... yes 60/123 ... yes 60/124 ... yes 60/125 ... yes 60/126 ... yes 60/127 ... yes 60/128 ... yes 60/129 ... yes 60/130 ... yes 60/131 ... yes 60/132 ... yes 60/133 ... yes 60/134 ... yes 60/135 ... yes 60/136 ... yes 60/137 ... yes 60/138 ... yes 60/139 ... yes 60/140 ... yes 60/141 ... yes 60/142 ... yes 60/143 ... yes 60/144 ... yes 60/145 ... yes 60/146 ... yes 60/147 ... yes 60/148 ... yes 60/149 ... yes 60/150 ... yes 60/151 ... yes 60/152 ... yes 60/153 ... yes 60/154 ... yes 60/155 ... yes 60/156 ... yes 60/157 ... yes 60/158 ... yes 60/159 ... yes 60/160 ... yes 60/161 ... yes 60/162 ... yes 60/163 ... yes 60/164 ... yes 60/165 ... yes 60/166 ... yes 60/167 ... yes 60/168 ... yes 60/169 ... yes 60/170 ... yes 60/171 ... yes 60/172 ... yes 60/173 ... yes 60/174 ... yes 60/175 ... yes 60/176 ... yes 60/178 ... yes 60/179 ... yes 60/180 ... yes 60/181 ... yes 60/182 ... yes 61/183 ... yes 66/184 ... yes 66/185 ... yes 65/186 ... yes 68/187 ... yes 70/188 ... yes 74/189 ... yes 74/190 ... yes 2/191 ... yes 75/192 ... yes 75/193 ... 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: ... 7 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 6.x - 7.x? ... skipped (elasticsearch is disabled)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished