[Issue] Fix exception handling inconsistency between developer and production modes #38639
Labels
Area: Framework
Component: Framework/Exception
Issue: Confirmed
Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed
Priority: P2
A defect with this priority could have functionality issues which are not to expectations.
Progress: PR Created
Indicates that Pull Request has been created to fix issue
Progress: PR in progress
Reported on 2.4.x
Indicates original Magento version for the Issue report.
Reproduced on 2.4.x
The issue has been reproduced on latest 2.4-develop branch
Projects
This issue is automatically created based on existing pull request: #37712: Fix exception handling inconsistency between developer and production modes
Description (*)
During developing our custom module was found an issue in the developer mode, for example, after implementing
\Magento\Customer\Controller\AccountInterface
class into the custom controller we got redirected to the login page (as was expected), but on the production on the same flow we got aninternal server error 500
.It happened because the redirect URL was set to the response before the trigger exception and as a result
Location
header was sent to the browser and the browser redirect to the login page instead of the page with an exception message.It's not expected flow between developer and production modes and can cause some issues for production.
Preconditions and environment
Steps to reproduce
app/code/Vendor/Module/registration.php
:app/code/Vendor/Module/etc/module.xml
:app/code/Vendor/Module/etc/frontend/routes.xml
:magento2/app/code/Vendor/Module/Controller/Example/Index.php
:www.domain.com/vendor/example
Expected result
Actual result
Unfortunately, I don't have enough experience with test coverage, will be great if someone covers this case by test.
Contribution checklist (*)
The text was updated successfully, but these errors were encountered: