-
Notifications
You must be signed in to change notification settings - Fork 11k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to get a 413 results in an empty message #53049
Comments
Created a small reproducer |
Don't see that the reproducing repository uses |
It uses it under the hood and is a default middleware. The PostTooLargeException is throw by it |
https://github.com/search?q=repo%3Alaravel%2Fframework%20PostTooLarge&type=code
|
It actually is included by default... see reproducer |
Hey @crynobone, I also think it is included by default in the global middleware stack: framework/src/Illuminate/Foundation/Configuration/Middleware.php Lines 403 to 419 in bc5bd66
|
@parijke could you also check if your web server has a restricting limit for post / file size in the php.ini or the nginx configuration:
|
The issue is not that I cannot set those values. The issue is that I cannot create a decent user message because the session is not started yet, while the documentation says this should be the way |
The session is not started, because the session start is in the First run the Can you show me, where in the docs it says, that the session is already started? |
|
It doesn't state in the docs that it is started... it is implicitly because of the 419 example in the docs. My point is if it should be considered to start a session before the |
A session is only used for browsers with cookies. You don't want to start a session, if you use for example API-Tokens, which are stateless. That is the reason for the |
That sounds reasonable... not sure how to handle this into a form validation then. Any ideas? |
Did you try catching |
@Jubeki Maybe I misunderstand, but this is in the same WithExceptions in the app.php, isn't it? Therefor, still no session is available to set the errors on. Or do I mis the point here? |
Sorry my bad, I now understand, that you want to write data to the session, a validation error, or another message. Yeah that is not possible in that way. You could of course catch the PostTooLargeException then Start the Session manually, but this would be quite a workaround and I am not sure if that would be the best way to achieve your desired behaviour. (I am not sure how you start the session manually, but taking a look into |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Laravel Version
11.26.0
PHP Version
8.3.12
Database Driver & Version
Postrgres 15
Description
When trying to handle a 413 error, thrown by the
ValidatePostSize
middleware like described here does not seem to work.https://laravel.com/docs/11.x/errors#customizing-the-exception-response
It appears that the session is not started (yet).
Steps To Reproduce
Create a handler for a 413 error response like https://laravel.com/docs/11.x/errors#customizing-the-exception-response
Post a huge file to a form. No error is shown.
The text was updated successfully, but these errors were encountered: