Review main Abandoned

89080[FEATURE] Improve default validation error in Controllers

Lina Wolf CR 0 V -1 Normal +116 −9 updated 10/25/26, 17:38

Commit message

Extbase's ActionController now provides more helpful and translated
flash messages when validation errors occur, avoiding technical messages
that expose class and method names.

When validation fails and forwarding to the referring action is
possible, a default message like

  "Please check the form and correct any errors."

is shown.

Developers can override the following new methods to adjust the flash
message or behavior as needed:

* `getValidationFailedFlashMessage(?Result $validationResult = null)`
* `validationFailedAction(?Result $validationResult = null)`

If forwarding is not possible, the default `errorAction()` remains as
fallback.

Review

  • Code review CR 0
  • Verified V -1
    • Torben Hansen -1
    • core-ci +1 CI

Issues 2

Files 4

Review log 4965

Show 3240 earlier messages
  1. Lina Wolf uploaded patch set 1 04/12/25, 06:55

  2. Lina Wolf uploaded patch set 2 04/12/25, 06:59

  3. core-ci voted on patch set 1 V -1 04/12/25, 07:06 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77607

  4. core-ci voted on patch set 2 V -1 04/12/25, 07:08 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77608

  5. Lina Wolf uploaded patch set 3 V -1 04/12/25, 07:23

  6. core-ci voted on patch set 3 V +1 04/12/25, 07:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77610

  7. Mathias Bolt Lesniak commented on patch set 3 04/12/25, 13:26

    A nice UX improvement, I think. I suggested some improvements to the change log entry.

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:17

    ```suggestion A localizable, user-friendly message will now be displayed by default: Something went wrong while processing your request. Please try again. This replaces highly technical messages that expose class/method names, like: ```

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:21

    ```suggestion ``` The suggestion above makes this line unnecessary and avoids breaking the sentence up across paragraphs.

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:24

    ```suggestion automatic flash messages on a site-by-site basis or using TypoScript: ```

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:30

    ```suggestion The default error flash message can now be suppressed without ```

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:31

    ```suggestion overriding the ActionController class. ``` More specific?

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:33

    ```suggestion Validation errors are now stored in the ActionController's protected property ```

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:34

    ```suggestion `$this->lastValidationResult`. This makes further processing and debugging easier. ```

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:41

    ```suggestion * Integrators can disable default error flash messages globally or per site. ``` Also, is "globally or per site" a too limited statement? Since TypoScript can be applied to e.g., any page, tree section, or condition, it is not limited to this. Or?

    ActionController.php:577

    Is "globally or per site" a too limited statement? Since TypoScript can be applied to e.g., any page, tree section, or condition, it is not limited to this.
  8. Garvin Hicking commented on patch set 3 04/12/25, 14:20

    How about emitting the current error message while n development context? I always kind of found it helpful while debugging to spot the actual controller and action name here.

    BlogPostEditingControllerTest.php:560

    we should add a testcase to this, with typoscript disabling default message, to verify this works
  9. Stefan Bürk commented on patch set 3 04/12/25, 15:35

    ActionController.php:437

    Please do not park the validation result in a property (state). Keep it here as local variable and pass it down to the error action (L450) ``` $actionResult = $this->{$this->errorMethodName}($validationResult); ``` and further to nested calls. Passing information is the better than property transport.

    ActionController.php:586

    This method should get the validation result passed in (nullable?) and not rely on a parked property state.

    ActionController.php:588

    Do we really need a new feature flag for it ? Why not simply `improving` the situation, what the core of this change aims for, and make it the default. And then again, the multi level flag setting every has an other opionen which should overrule what and so on. Could that simply be left out ? Extbase Plugin authors can still override this method and implement it on there own if they really want to provide such a feature or hide it away. And it should be the desicion of the extbase plugin author if default or a custom message is display. Just questioning, extbase experienced developers may have more insight in this.
  10. Lina Wolf commented on patch set 3 04/12/25, 16:51

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:31 Reply

    You are always extending the ActionController when you build your own Controller
  11. Lina Wolf marked it work in progress 04/12/25, 16:51

  12. Lina Wolf commented on patch set 3 04/12/25, 17:17

    Reply

    How would you feel about adding it to the debug output or the log instead? While developing locally I want to make sure that the error messages shown to the end user are helpful to them?
  13. Garvin Hicking commented on patch set 3 04/12/25, 17:43

    Reply

    True. I guess putting it in the debug-level log would be good by me (no context evaluation needed, the logging context will decide this then)

    ActionController.php:588 Reply

    This is a good point to discuss! (thinking out loud now) Extbase has some 'mvc.showPageNotFoundIfTargetNotFoundException' and 'mvc.showPageNotFoundIfRequiredArgumentIsMissingException', so maybe if we would use that scope it would be more fitting? BUT: The benefit of having this as a central flag is, that it would create the expectation to be respected in EVERY existing extension, so an integrator could configure the message then, and not the Extbase extension developer would need to code errorFlashMessageHandling individually. Then again - if extension developers actually override this method (which MANY do, myself included), then having a setting would never get evaluated and an integrator can never be sure if this setting is respected in all extensions or not. So.... the current default is not great, so I tend to agree and not overcomplicate it with a setting that might be misleading, and just make the new reporting the default. With the default referring to a translation string, integrators could also override that string, so that might be "good enough"?
  14. Lina Wolf commented on patch set 3 04/13/25, 06:20

    ActionController.php:437 Reply

    Acknowledged

    ActionController.php:586 Reply

    If we do that we are causing a fatal error to anyone who is overriding the method in their controller. Therefore overriding the method and supporting both TYPO3 v13 and 14 would not be possible anymore. Even worse we would also have to change the signature of the default error action `errorAction()`, which is frequently overridden. So if anyone was overriding one of them - and this is common practice - they could not support TYPO3 13 and 14 anymore with the same controller. Therefore, I introduced new methods now in case validation failed, falling . This also enables extension authors to separately override the general error message and the one caused by a wrongly filled out form.

    ActionController.php:588 Reply

    I will remove id for now.
  15. Lina Wolf uploaded patch set 4 V +1 04/13/25, 06:20

  16. Lina Wolf commented on patch set 4 04/13/25, 06:23

    This change is ready for review.

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:17 Reply

    section was removed

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:21 Reply

    Acknowledged

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:24 Reply

    section was removed

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:30 Reply

    section was removed

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:31 Reply

    Acknowledged

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:33 Reply

    section was removed

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:34 Reply

    section was removed

    Feature-106462-ConfigurableAndUser-friendlyErrorFlashMessagesInActionController.rst:41 Reply

    section was removed
  17. Lina Wolf commented on patch set 4 04/13/25, 06:24

    ActionController.php:577 Reply

    A localizable, user-friendly message will now be displayed by default:
  18. Lina Wolf commented on patch set 4 04/13/25, 06:25

    ActionController.php:586 Reply

    I solved it in another way
  19. Lina Wolf commented on patch set 4 04/13/25, 06:26

    Reply

    Done
  20. Lina Wolf commented on patch set 4 04/13/25, 06:26

    BlogPostEditingControllerTest.php:560 Reply

    Section was removed
  21. Lina Wolf commented on patch set 4 04/13/25, 06:29

    ActionController.php:588 Reply

    I wonder if we should also treat an empty error message as disabling the flash message. Then you could disable the flash message by overriding the error message with an empty string?
  22. core-ci voted on patch set 4 V -1 04/13/25, 06:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77667

  23. Lina Wolf uploaded patch set 5 V -1 04/13/25, 07:18

  24. Lina Wolf updated the commit message in patch set 6 04/13/25, 07:21

  25. core-ci voted on patch set 5 V +1 04/13/25, 07:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77669

  26. core-ci voted on patch set 6 V +1 04/13/25, 07:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77670

  27. Lina Wolf updated the commit message in patch set 7 V +1 04/13/25, 07:43

  28. core-ci voted on patch set 7 V +1 04/13/25, 07:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77671

  29. Christian Kuhn commented on patch set 7 04/14/25, 12:23

    Services.yaml:11

    these 2 lines should be avoided. why do you reconfigure global logging within this extension?
  30. Lina Wolf commented on patch set 8 V +1 04/14/25, 12:25

    Published edit on patch set 7.
  31. Christian Kuhn commented on patch set 7 CR -1 04/14/25, 12:25

    ActionController.php:623

    use an inject* method to get a logger injected. no need to use the logManager at all. see other use cases within core.
  32. Lina Wolf commented on patch set 8 04/14/25, 12:25

    Services.yaml:11 Reply

    Done
  33. Lina Wolf commented on patch set 8 04/14/25, 12:28

    ActionController.php:623 Reply

    That was what I tried intially. However it seems like injection the LoggerInterface via DI does not work in Extbase. In whole of Exbase I only found one usage of the Logger and there it was referenced in the exact way that I duplicated here. When you try to inject the logger, all tests are failing.
  34. core-ci voted on patch set 8 V +1 04/14/25, 12:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77699

  35. Stefan Bürk commented on patch set 8 04/14/25, 20:51

    ActionController.php:623 Reply

    To note it for other reviewes: Lina tried already what lolli mentioned in changeset 4, which failed. The reason for this is, that LoggerInterface is not defined to be method injectable, the related compiler pass register this only for constructor injection. That means, we should have a look into that first (pre-patch) if that can be added first and then rework this change to get the logger injected using the inject method. @112@linawolf.de I set this change to WIP for now, hope that is okay for you.
  36. Stefan Bürk marked it work in progress 04/14/25, 20:51

  37. Lina Wolf commented on patch set 8 04/18/25, 11:29

    ActionController.php:623 Reply

    @stefan@buerk.tech yes it is ok, is there a forge ticket about this already so that I can follow along??
  38. Lina Wolf commented on patch set 8 04/25/25, 15:08

  39. Stefan Bürk uploaded patch set 9 V +1 04/27/25, 12:52

  40. Stefan Bürk commented on patch set 9 04/27/25, 12:55

    ActionController.php:623 Reply

    See https://review.typo3.org/c/Packages/TYPO3.CMS/+/89244 which configures `LoggerInterface` for method injection along with a bunch of tests for it. I replaced the GU::makeInstance() for the logger with a method injection of the logger interface now for this change, basing it (relation chain) on the aforementioned changed making that change a blocker for this change, but it is prepared to reviewed and mergable afterwards.
  1. Stefan Bürk updated the commit message in patch set 10 04/27/25, 12:56

  2. core-ci voted on patch set 9 V +1 04/27/25, 13:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78228

  3. core-ci voted on patch set 10 V +1 04/27/25, 13:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78230

  4. Stefan Bürk rebased onto patch set 11 V +1 04/27/25, 15:14

  5. core-ci voted on patch set 11 V +1 04/27/25, 15:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78240

  6. Lina Wolf uploaded patch set 12 V +1 11/13/25, 13:11

  7. Lina Wolf marked it ready for review 11/13/25, 13:12

  8. Stefan Bürk commented on patch set 12 11/13/25, 13:14

    ActionController.php:623 Reply

    It seems that allowing logger injection based on inject method needs some time to discuss the concrete implementation, we should stay with the logger aware interface and trait tuple - to unblock this change for now.
  9. Lina Wolf commented on patch set 12 11/13/25, 13:15

    ActionController.php:623 Reply

    Acknowledged
  10. Lina Wolf uploaded patch set 13 11/13/25, 13:17

  11. core-ci voted on patch set 13 V +1 11/13/25, 13:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89500

  12. core-ci voted on patch set 12 V -1 11/13/25, 13:30 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89499

  13. core-ci voted on patch set 12 V -1 11/14/25, 04:05 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/89499

  14. Lina Wolf uploaded patch set 14 V +1 12/02/25, 15:56

  15. core-ci voted on patch set 14 V +1 12/02/25, 16:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/91457

  16. Simon Schaufelberger commented on patch set 14 12/03/25, 08:02

    Feature-106462-ImproveFailedValidationErrorHandlingInExtbaseActionController.rst:1

    Move to 14.1
  17. Lina Wolf uploaded patch set 15 V +1 12/03/25, 08:05

  18. Lina Wolf commented on patch set 15 12/03/25, 08:05

    Feature-106462-ImproveFailedValidationErrorHandlingInExtbaseActionController.rst:1 Reply

    Done
  19. core-ci voted on patch set 15 V +1 12/03/25, 08:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/91507

  20. Torben Hansen commented on patch set 15 V -1 12/03/25, 09:04

    This change is some kind of breaking, results in unexpected behavior and requires additional function implementation by most extension authors. In the current state of the patch, the `validationFailedAction` will always return the translated error message from `getValidationFailedFlashMessage()`. Users updating from previous TYPO3 versions and who suppress the flash messages via `getErrorFlashMessage()` returning `false` will now always see the flash message from `getValidationFailedFlashMessage()`. Additionally, if an extension provides a custom flash message in `getErrorFlashMessage()` this will now also not be shown any more, because the new `validationFailedAction()` basically takes over the validation error forwarding, so `errorAction()` will never be called. The validation error forward-handling in `validationFailedAction()` must therefore be removed, so the configured `errorMethodName` will be called again. I'm however really unsure about the change and the new default message generated by `getValidationFailedFlashMessage()`, because extension authors now must **overwrite two methods**, if they do not want any kind of validation/error flash messages generated by extbase action controller. I also think, that we already have the suggested functionality (=> `getErrorFlashMessage()`) in place, it currently just does not return a meaningful message. So basically, it would be a helpfull improvement to just improve the default message generated by `getErrorFlashMessage()` and to add logging in that function.
  21. Garvin Hicking commented on patch set 15 02/20/26, 09:10

    Reply

    That sounds logical to me to do the logging and improved output in the getErrorFlashMessage. Lina, would you be interested to move the patch forward before feature freeze?
  22. Garvin Hicking commented on patch set 15 02/20/26, 09:11

    Ah sorry, now I see the cross-dependency to the logger injection to https://review.typo3.org/c/Packages/TYPO3.CMS/+/91984.
  23. Torben Hansen commented on patch set 15 02/20/26, 09:15

    Reply Unresolved

    As I wrote, we already have code in place and the change is breaking/non functional. I suggest to only improve the default message and to avoid introducing a new function here, which basically does the same as `getErrorFlashMessage()`
  24. Christian Kuhn wrote 06/18/26, 23:07

    Removed reviewer Christian Kuhn.
  25. Lina Wolf abandoned the change 10/25/26, 17:38