1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-31 11:37:14 +00:00

Return 406 status code instead of 500 when API request has an invalid format (#34766).

Patch by Felix Schäfer.


git-svn-id: http://svn.redmine.org/redmine/trunk@21392 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu 2022-01-30 13:39:06 +00:00
parent ca3f4d0e0a
commit 9f6d8711e7

View File

@ -30,7 +30,9 @@ module Redmine
when 'xml', :xml then Builders::Xml.new(request, response)
when 'json', :json then Builders::Json.new(request, response)
else
raise "No builder for format #{format}"
Rails.logger.error "No builder for format #{format.inspect}"
response.status = 406
return "We couldn't handle your request, sorry. If you were trying to access the API, make sure to append .json or .xml to your request URL.\n"
end
if block_given?
yield(builder)