Skip to content

Commit ea2336b

Browse files
committed
failure to parse params should trigger a 400 Bad Request
1 parent ecfdc84 commit ea2336b

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

actionpack/lib/action_dispatch/middleware/exception_wrapper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class ExceptionWrapper
1212
'ActionController::NotImplemented' => :not_implemented,
1313
'ActionController::UnknownFormat' => :not_acceptable,
1414
'ActionController::InvalidAuthenticityToken' => :unprocessable_entity,
15+
'ActionDispatch::ParamsParser::ParseError' => :bad_request,
1516
'ActionController::BadRequest' => :bad_request,
1617
'ActionController::ParameterMissing' => :bad_request
1718
)

actionpack/test/dispatch/show_exceptions_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ def call(env)
88
case req.path
99
when "/not_found"
1010
raise AbstractController::ActionNotFound
11+
when "/bad_params"
12+
raise ActionDispatch::ParamsParser::ParseError.new("", StandardError.new)
1113
when "/method_not_allowed"
1214
raise ActionController::MethodNotAllowed
1315
when "/not_found_original_exception"
@@ -33,6 +35,10 @@ def call(env)
3335
get "/", {}, {'action_dispatch.show_exceptions' => true}
3436
assert_response 500
3537
assert_equal "500 error fixture\n", body
38+
39+
get "/bad_params", {}, {'action_dispatch.show_exceptions' => true}
40+
assert_response 400
41+
assert_equal "400 error fixture\n", body
3642

3743
get "/not_found", {}, {'action_dispatch.show_exceptions' => true}
3844
assert_response 404
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
400 error fixture

0 commit comments

Comments
 (0)