From 68bb53a196e5c3856c0bad5c3d76b4b4cdb8105c Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Wed, 28 Jun 2023 08:17:11 +0800 Subject: [PATCH] DEV: Fix failing spec after Rails upgrade to 7.0.5.1 (#22317) Follow up to 4d3999de1026c7c6ede40bff1d9e394b94dccc2b --- lib/middleware/discourse_public_exceptions.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/middleware/discourse_public_exceptions.rb b/lib/middleware/discourse_public_exceptions.rb index 931910cb002..54e070c433a 100644 --- a/lib/middleware/discourse_public_exceptions.rb +++ b/lib/middleware/discourse_public_exceptions.rb @@ -49,12 +49,16 @@ module Middleware # Or badly formatted multipart requests begin request.POST - rescue EOFError - return [ - 400, - { "Cache-Control" => "private, max-age=0, must-revalidate" }, - ["Invalid request"] - ] + rescue ActionController::BadRequest => error + if error.cause.is_a?(EOFError) + return [ + 400, + { "Cache-Control" => "private, max-age=0, must-revalidate" }, + ["Invalid request"] + ] + else + raise + end end if ApplicationController.rescue_with_handler(exception, object: fake_controller)