ActionController::RespondToMismatchError in wiki controller
https://sentry.gitlab.net/gitlab/gitlabcom/issues/1726282/?referrer=gitlab_plugin
ActionController::RespondToMismatchError: respond_to was called multiple times and matched with conflicting formats in this action. Please note that you may only call respond_to and match on a single format per action.
(144 additional frame(s) were not displayed)
...
active_support/callbacks.rb:428:in `block in make_lambda'
target.send(method, *arguments, &block)
projects/application_controller.rb:61:in `method_missing'
authorize_action!($1.to_sym)
projects/application_controller.rb:45:in `authorize_action!'
access_denied!
application_controller.rb:215:in `access_denied!'
respond_to do |format|
action_controller/metal/mime_responds.rb:209:in `respond_to'
raise ActionController::RespondToMismatchError
ActionController::RespondToMismatchError: respond_to was called multiple times and matched with conflicting formats in this action. Please note that you may only call respond_to and match on a single format per action.
Issue was refined in #237798 (closed).
Permissions and Security
None.
Documentation
None.
Availability & Testing
Controller tests.
Recommended MR Breakdown
1 MR.
Proposed solution
See the upstream issue where two workarounds were proposed: https://github.com/rails/rails/issues/40023#issuecomment-673675138
- Swap the order in
access_denied!
soformat.html
comes first.- This means we'd return a HTML response for a client sending
Accept: */*
.
- This means we'd return a HTML response for a client sending
- Explicitly check for
request.formats.include?(Mime::ALL)
inaccess_denied!
.- This means we'd return a header-only response for a client sending
Accept: */*
.
- This means we'd return a header-only response for a client sending
Edited by Markus Koller