Replies: 18 comments 3 replies
-
Created a small reproducer |
Beta Was this translation helpful? Give feedback.
-
Don't see that the reproducing repository uses |
Beta Was this translation helpful? Give feedback.
-
It uses it under the hood and is a default middleware. The PostTooLargeException is throw by it |
Beta Was this translation helpful? Give feedback.
-
https://github.com/search?q=repo%3Alaravel%2Fframework%20PostTooLarge&type=code
|
Beta Was this translation helpful? Give feedback.
-
It actually is included by default... see reproducer |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
@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:
|
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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? |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
That sounds reasonable... not sure how to handle this into a form validation then. Any ideas? |
Beta Was this translation helpful? Give feedback.
-
Did you try catching |
Beta Was this translation helpful? Give feedback.
-
@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? |
Beta Was this translation helpful? Give feedback.
-
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 |
Beta Was this translation helpful? Give feedback.
-
I managed to get it working by setting the priority of the middleware. See the latest commit in the reproducer. What I cannot predict are the possible disadvantages. Any ideas? |
Beta Was this translation helpful? Give feedback.
-
It appears Symfony does more ore less the same. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
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.
Beta Was this translation helpful? Give feedback.
All reactions