"Can't verify CSRF token authenticity"
Summary
Closing some (but not all) merge requests does not work. This error happens inside a Docker environment (Docker 17.06.0-ce, image gitlab/gitlab-ce:9.4.2-ce.0), behind a SSL termination engine (haproxy). In case it matters, the configuration is supplied by Docker: -e GITLAB_OMNIBUS_CONFIG="external_url 'http://git.xxx.de/'; registry_external_url 'http://git.xxx.de:50000/';"
Steps to reproduce
- Create a MR
- Click on "close merge request"
What is the current bug behavior?
An Error 422 ("The change you requested was rejected.") screen appears. The MR is still open.
What is the expected correct behavior?
No error message, the MR should be closed.
Relevant logs and/or screenshots
Started PUT "/XXX/XXX/merge_requests/106?merge_request%5Bstate_event%5D=close" for 172.17.0.1 at 2017-08-01 11:21:35 +0000
Processing by Projects::MergeRequestsController#update as HTML
Parameters: {"merge_request"=>{"state_event"=>"close"}, "namespace_id"=>"XXX", "project_id"=>"XXX", "id"=>"106"}
Can't verify CSRF token authenticity
Completed 422 Unprocessable Entity in 5ms (ActiveRecord: 0.7ms)
ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
lib/gitlab/performance_bar/peek_performance_bar_with_rack_body.rb:16:in `call'
lib/gitlab/middleware/multipart.rb:93:in `call'
lib/gitlab/request_profiler/middleware.rb:14:in `call'
lib/gitlab/middleware/go.rb:16:in `call'
lib/gitlab/etag_caching/middleware.rb:11:in `call'
lib/gitlab/request_context.rb:18:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:27:in `call'
Output of checks
(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)
Results of GitLab environment info
Expand for output related to 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 Redis Version: 3.2.5 Git Version: 2.13.0 Sidekiq Version:5.0.0 Go Version: unknown
GitLab information Version: 9.4.2 Revision: a2ffceb Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: http://git.xxx.de HTTP Clone URL: http://git.xxx.de/some-group/some-project.git SSH Clone URL: [git@git.xxx:16122]:some-group/some-project.git Using LDAP: yes Using Omniauth: no
GitLab Shell Version: 5.3.1 Repository storage paths:
- default: /gitlab-data/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab Shell ...GitLab Shell version >= 5.3.1 ? ... OK (5.3.1) Repo base directory exists? default... yes Repo storage directories are symlinks? default... no Repo paths owned by git:root, or git:git? default... yes Repo paths access is drwxrws---? default... yes hooks directories in repos are links: ... 2/9 ... ok 2/10 ... repository is empty 6/12 ... ok 6/13 ... ok 6/14 ... ok 6/15 ... ok 6/16 ... ok 6/17 ... ok 2/18 ... ok 6/19 ... ok 6/20 ... ok 6/21 ... ok 7/22 ... ok 7/23 ... ok 5/24 ... ok 2/25 ... ok 5/26 ... ok 2/27 ... ok 2/28 ... ok 2/29 ... ok 2/30 ... ok 2/31 ... ok 6/32 ... ok 6/33 ... ok 5/34 ... ok 6/35 ... ok 2/36 ... ok 2/37 ... ok 2/38 ... ok 2/39 ... ok 2/40 ... ok 2/41 ... ok 7/44 ... ok 7/45 ... ok 2/48 ... ok 2/50 ... ok 6/51 ... ok 6/52 ... ok 6/53 ... ok Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Access to /gitlab-data/home/.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 ...
Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) XXXXXXXXX Checking LDAP ... Finished
Checking GitLab ...
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/9 ... yes 2/10 ... yes 6/12 ... yes 6/13 ... yes 6/14 ... yes 6/15 ... yes 6/16 ... yes 6/17 ... yes 2/18 ... yes 6/19 ... yes 6/20 ... yes 6/21 ... yes 7/22 ... yes 7/23 ... yes 5/24 ... yes 2/25 ... yes 5/26 ... yes 2/27 ... yes 2/28 ... yes 2/29 ... yes 2/30 ... yes 2/31 ... yes 6/32 ... yes 6/33 ... yes 5/34 ... yes 6/35 ... yes 2/36 ... yes 2/37 ... yes 2/38 ... yes 2/39 ... yes 2/40 ... yes 2/41 ... yes 7/44 ... yes 7/45 ... yes 2/48 ... yes 2/50 ... yes 6/51 ... yes 6/52 ... yes 6/53 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.3 ? ... yes (2.3.3) Git version >= 2.7.3 ? ... yes (2.13.0) Active users: ... 63
Checking GitLab ... Finished
Possible fixes
Apparently there is a similar problem at #35452 (closed), but this is a different controller.