Open diegoflorez opened 1 month ago
@bennothommo any thoughts?
@diegoflorez this is partially intended, based on the behavior of the previous AJAX framework.
Validation errors in the PHP side are returned with a response code of HTTP 406 Not Acceptable, which in the old framework was interpreted as a "successful" response, because it may include partial updates (such as displaying said validation errors in a specific way in a component, for example). Thus, the validation errors are simply returned as response data, and we have kept that behavior intact with Snowboard.
However, the responseError
variable is reserved for the main exception message and should be passed through, but it appears it may not be. So that particular part of the functionality may have a bug.
Winter CMS Build
1.2
PHP Version
8.1
Database engine
MySQL/MariaDB
Plugins installed
No response
Issue description
When submitting a form using
Snowboard.request
in WinterCMS, validation errors that should be caught in theresponseError
of theerror
handler are instead returned in theresponseData
of theerror
handler.The expected behavior is that validation errors, when thrown as a
ValidationException
, should be returned inresponseError
. However, they are currently being returned inresponseData
, which is inconsistent with the expected Snowboard behavior for error handling.Steps to replicate
ValidationException
class.Form Partial (HTML + JS)
Backend Handler (PHP)
Expected Behavior:
When a
ValidationException
is thrown, the error response should be captured inresponseError
in theerror
handler of theSnowboard.request
.Actual Behavior:
responseData
instead ofresponseError
.responseError
isnull
in theerror
function.Possible Fix:
Ensure that validation errors, when thrown as
ValidationException
, are returned in theresponseError
instead ofresponseData
.Environment:
Thank you for looking into this issue!
Workaround
No response