Review main Merged

81755[FEATURE] Improve handling of finisher exceptions

Georg Ringer CR +2 V +2 Normal +121 −21 updated 10/27/25, 18:16

Commit message

FinisherException are now caught and a user-friendly,
modifiable error message is displayed in the frontend.
The exception is also logged.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Garvin Hicking +1
    • Josua Vogel +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Garvin Hicking +1
    • Josua Vogel +1
    • core-ci +1 CI

Issues 4

Files 16

Review log 6890

Show 4965 earlier messages
  1. Georg Ringer uploaded patch set 1 11/16/23, 07:27

  2. Georg Ringer commented on patch set 1 11/16/23, 07:27

    This change is ready for review.
  3. core-ci voted on patch set 1 V -1 11/16/23, 07:34 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/49004

  4. Georg Ringer commented on patch set 2 V -1 11/16/23, 12:18

    Published edit on patch set 1.
  5. core-ci voted on patch set 2 V +1 11/16/23, 12:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/49018

  6. Oliver Klee commented on patch set 2 11/17/23, 10:56

    Looks very good functionality-wise. I've added a comment about a line that should be moved to still make sense.

    EmailFinisher.php:161

    This comment should stay direct above the line with the `makeInstance` call, i.e., it should be inside the `try`.
  7. Oli Bartsch commented on patch set 2 11/17/23, 12:00

    EmailFinisher.php:164

    Could we be more specific please. Catching top-level exceptions should IMO be avoided wherever possible.
  8. Christian Kuhn commented on patch set 2 CR -1 11/19/23, 11:36

    EmailFinisher.php:164 Reply

    Yeah. And this more specific catch should probably be in core/Mailer section, probably around the 'transport' secetino? and not here.
  9. Georg Ringer commented on patch set 2 11/20/23, 07:35

    EmailFinisher.php:164 Reply

    unsure about exception handling in core/mailer as this leads to more side effects
  10. Georg Ringer commented on patch set 2 03/12/24, 07:36

    I want to bring that up again and IMO any exception which is triggered during the mail sending or persisting need to be caught to avoid a "error happened" for the user
  11. Oliver Klee wrote 08/25/24, 10:11

    Removed cc Oliver Klee.
  12. Benni Mack updated the commit message in patch set 3 CR -1 V +1 10/18/24, 13:46

  13. Benni Mack rebased onto patch set 4 01/08/25, 16:42

  14. core-ci voted on patch set 4 V +1 01/08/25, 16:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/72106

  15. Patrick Schriner commented on patch set 4 01/08/25, 17:00

    Wouldn't this (and really unchangeable) change current behavior? Given 2 Finishers, if A failed formerly B would not be executed Now A would fail but B would be executed? While I like the logging there is no way to catch that exception gracefully. Wouldn't the real solution be something like catching the exception, throwing a FinisherException with the previous exception as previous and having a way to catch that FinisherException in a good way? FinisherException are still thrown in the code btw, and why are these final calls the only ones caught?
  16. Benni Mack wrote 03/28/25, 09:16

    Topic set to form
  17. Stephan Großberndt commented on patch set 4 07/30/25, 10:05

    Reply

    I agree "silently" logging and continuing would be a change in behaviour. Consider a form with A:EmailToSenderFinisher and B:SaveToDatabaseFinisher. If sending the mail fails due to an invalid address, e.g. as reported in https://forge.typo3.org/issues/107171 you would not want to save the record but ask the user to correct the address. (The invalid address could be found out beforehand by validEmail if it would do the DNSCheckValidation but this is not enabled by default.) If sending the email fails although the address is valid (e.g. temporary SMTP failure) you could want to save the record to the database nonetheless. But you would have the option to do so by changing the order of the finishers to A:SaveToDatabaseFinisher and B:EmailToSenderFinisher. Therefore I think the behaviour should not be changed to log only but throw a FinisherException instead. Distinguishing the cases "fail because invalid" vs. "fail although valid" and throwing specific exeptions could be done in the core Mailer (or even symfony mailer?) making it easier to react on it differently.
  18. Josua Vogel uploaded patch set 5 V +1 08/01/25, 11:41

  19. core-ci voted on patch set 5 V -1 08/01/25, 11:51 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82630

  20. Josua Vogel commented on patch set 5 08/01/25, 11:55

    Reply

    I have updated the patch. A FinisherException is now thrown.
  21. Josua Vogel uploaded patch set 6 V -1 08/01/25, 12:09

  22. core-ci voted on patch set 6 V +1 08/01/25, 12:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/82632

  23. Josua Vogel commented on patch set 6 08/01/25, 14:12

    Reply

    I've thought about it again: Throwing a FinisherException does not improve the previous behavior at all. The correct thing to do would be to log the exception and then display a general error message.
  24. Josua Vogel commented on patch set 6 09/22/25, 13:05

    EmailFinisher.php:161 Reply

    Done

    EmailFinisher.php:164 Reply

    Done
  25. Josua Vogel commented on patch set 6 09/22/25, 13:05

    Reply

    Acknowledged
  26. Josua Vogel uploaded patch set 7 V +1 09/22/25, 13:08

  27. Chris Müller commented on patch set 7 09/22/25, 13:18

    SaveToDatabaseFinisher.php:229

    The return annotation is now superfluous.

    SaveToDatabaseFinisherTest.php:130

    Why not using the Psr\Log\NullLogger, then no mock is needed? Also below.
  28. core-ci voted on patch set 7 V -1 09/22/25, 13:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85300

  29. Josua Vogel uploaded patch set 8 V -1 09/22/25, 13:37

  30. core-ci voted on patch set 8 V +1 09/22/25, 13:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85302

  31. Josua Vogel commented on patch set 8 09/22/25, 13:49

    SaveToDatabaseFinisher.php:229 Reply

    Done

    SaveToDatabaseFinisherTest.php:130 Reply

    Done
  32. Josua Vogel voted on patch set 8 CR +1 V +1 09/23/25, 15:05

  33. Stephan Großberndt updated the commit message in patch set 9 CR +1 V +1 09/25/25, 09:07

  34. core-ci voted on patch set 9 V +1 09/25/25, 09:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85494

  35. Josua Vogel voted on patch set 9 CR +1 V +1 09/25/25, 11:17

  36. Stephan Großberndt commented on patch set 9 CR +1 V -1 09/26/25, 11:54

    Reply

    > Acknowledged
    After testing the change, I agree with Josua: > Throwing a FinisherException does not improve the previous behaviour at all. The problem was reported due to the poor user experience in the frontend: If an email could not be sent or a record could not be saved to the database, the frontend user currently receives a complete TYPO3 HTTP 503 error page with the text "503 - Oops, an error occurred! - Failed to send the email: Unable to write bytes on the wire." instead of the rendered frontend page with a formatted error message at the location of the form. I had the impression that FinisherExceptions were already being caught and rendered in the frontend, but that is not the case. Throwing a `FinisherException` improves the situation in this regard, as it is now easier to catch these exceptions and render error messages, but this part is still missing.
  37. Josua Vogel commented on patch set 9 09/26/25, 13:08

    Reply

    Hi @stephan.grossberndt@typo3.org, would it be acceptable for you if we accept the improved error handling for now and open a new user story/feature request for rendering an error message?
  38. Stephan Großberndt updated the commit message in patch set 10 CR +1 V +1 10/01/25, 14:00

  39. Stephan Großberndt commented on patch set 10 CR +1 V +1 10/01/25, 14:06

    Reply

    I have updated the description to match the current user experience. I understand it is probably rather a feature (for TYPO3 v14 ?) than a bugfix to show the user-friendly error message on the form page instead of a full HTTP 503 error page with the message “An error has occurred”. I am fine with merging this as a bugfix but in my opinion neither https://forge.typo3.org/issues/102378 nor https://forge.typo3.org/issues/107171 should be closed when merging it - or another issue should be created and reference those.
  40. core-ci voted on patch set 10 V -1 10/01/25, 14:08 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85824

  41. Josua Vogel uploaded patch set 11 CR +1 V +1 10/01/25, 15:00

  42. Josua Vogel voted on patch set 11 CR +1 V +1 10/01/25, 15:00

  43. Josua Vogel commented on patch set 11 10/01/25, 15:05

  44. core-ci voted on patch set 11 V +1 10/01/25, 15:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85827

  45. Josua Vogel updated the commit message in patch set 12 CR +1 V +1 10/01/25, 15:06

  46. Garvin Hicking commented on patch set 12 10/01/25, 15:12

    EmailFinisher.php:87

    do we need those type changes in a bugfix? For a backport this might create issues since classes might be extended or xclassed and such?

    EmailFinisher.php:173

    I think when I tried this at some point DI did not work here for memory mailer instances. Is this verified to work with all interface variants we support?
  47. core-ci voted on patch set 12 V +1 10/01/25, 15:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85828

  48. Josua Vogel uploaded patch set 13 V +1 10/02/25, 15:32

  49. Josua Vogel commented on patch set 13 10/02/25, 15:33

    EmailFinisher.php:87 Reply

    changed to feature, because I added an frontend error message

    EmailFinisher.php:173 Reply

    I couldn't find any problems.
  50. core-ci voted on patch set 13 V -1 10/02/25, 15:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85930

  51. Josua Vogel uploaded patch set 14 V -1 10/02/25, 15:43

  52. core-ci voted on patch set 14 V -1 10/02/25, 15:50 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85932

  53. Josua Vogel uploaded patch set 15 V -1 10/02/25, 15:52

  54. core-ci voted on patch set 15 V +1 10/02/25, 15:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/85933

  55. Stephan Großberndt commented on patch set 15 CR +1 10/05/25, 11:35

    This looks great! Thanks a lot, Josua!
  56. Josua Vogel voted on patch set 15 CR +1 V +1 10/07/25, 12:45

  57. Josua Vogel updated the commit message in patch set 16 CR +1 V +1 10/23/25, 06:49

  58. core-ci voted on patch set 16 V +1 10/23/25, 06:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87380

  59. Josua Vogel voted on patch set 16 CR +1 V +1 10/23/25, 06:58

  60. Garvin Hicking commented on patch set 16 10/23/25, 09:41

    Feature-107581-ImproveHandlingOfFinisherException.rst:17

    ```suggestion The error message can be customized for each finisher using the new :yaml:`errorMessage` option. ```

    Feature-107581-ImproveHandlingOfFinisherException.rst:19

    The ReST file should also mention the newly introduced "Error" template which can be customized

    ConfirmationFinisher.php:63

    Isn't this a breaking change for any custom finishers that extend from AbstractFinisher, because $viewFactory is set there and maybe incompatible with the method injected non-readonly viewFactory?

    EmailFinisher.php:76

    Since the class isn't internal I think this might also need mentioning that it could be breaking for implementations, where calls to the parent constructor would need adoption. I think with the scope of this patch we could better keep the GU:MI approach (and do a change like this in a dedicated "breaking cleanup" patch)

    locallang.xlf:133

    ```suggestion <source>Your form could not be submitted due to a technical issue. The error was logged, it might be a temporary issue, but can also be related to your input (malformed mail addresses).</source> ``` Not sure if this is that much better, but some failures might not be temporary and this would give the illusion it is one? Also we could specifically mentioned the most likely error of failure, which is an "odd" mail address.
  61. Josua Vogel commented on patch set 16 10/23/25, 09:56

    Feature-107581-ImproveHandlingOfFinisherException.rst:17 Reply

    Fix applied.

    locallang.xlf:133 Reply

    I would delete the parts “The error was logged,” and "(malformed mail addresses)", because the error is shown to the website user. I don´t think the email is the most likely error of failure, we have many custom finishers with other temporary errors. I would like to keep the default error message general.
  62. Josua Vogel commented on patch set 17 CR +1 V +1 10/23/25, 09:59

    Published edit on patch set 16.
  63. core-ci voted on patch set 17 V +1 10/23/25, 10:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87398

  64. Josua Vogel uploaded patch set 18 V +1 10/23/25, 10:24

  65. Josua Vogel commented on patch set 18 10/23/25, 10:26

    Feature-107581-ImproveHandlingOfFinisherException.rst:19 Reply

    Done

    ConfirmationFinisher.php:63 Reply

    I changed the viewFactory inside AbstractFinisher to private

    EmailFinisher.php:76 Reply

    Done

    locallang.xlf:133 Reply

    Done
  1. Josua Vogel uploaded patch set 19 10/23/25, 10:29

  2. core-ci voted on patch set 18 V -1 10/23/25, 10:33 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87400

  3. core-ci voted on patch set 19 V +1 10/23/25, 10:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87401

  4. Josua Vogel uploaded patch set 20 V +1 10/23/25, 11:17

  5. core-ci voted on patch set 20 V +1 10/23/25, 11:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87408

  6. Josua Vogel voted on patch set 20 CR +1 V +1 10/23/25, 12:00

  7. Garvin Hicking commented on patch set 20 10/23/25, 13:54

    ConfirmationFinisher.php:63

    Is this one still required? Doesn't seem to be called anymore?
  8. Josua Vogel commented on patch set 20 10/23/25, 14:02

    ConfirmationFinisher.php:63 Reply

    it´s called in line 111
  9. Garvin Hicking commented on patch set 20 10/23/25, 16:20

    ConfirmationFinisher.php:63 Reply

    Thanks - I was wondering why this file shows up in the general diff though, I see no changes. Weird.
  10. Josua Vogel updated the commit message in patch set 21 CR +1 V +1 10/23/25, 18:23

  11. core-ci voted on patch set 21 V +1 10/23/25, 18:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87438

  12. Josua Vogel voted on patch set 21 CR +1 V +1 10/23/25, 20:38

  13. Simon Schaufelberger commented on patch set 21 10/23/25, 21:24

    SaveToDatabaseFinisher.php:238

    why was this changed?
  14. Josua Vogel commented on patch set 21 10/24/25, 05:49

    SaveToDatabaseFinisher.php:238 Reply

    getElementByIdentifier returns FormElementInterface|null, so this can be simplified
  15. Garvin Hicking commented on patch set 21 10/24/25, 11:11

    AbstractFinisher.php:139

    Talked with Stefan Bürk about this - we might want to use a `injectViewFactoryInterface()` method here, also the same with `injectTranslationService()` - if the finishers are DI-aware (I think they are).
  16. Josua Vogel uploaded patch set 22 CR +1 V +1 10/24/25, 13:59

  17. Josua Vogel commented on patch set 22 10/24/25, 13:59

    AbstractFinisher.php:139 Reply

    Done
  18. core-ci voted on patch set 22 V -1 10/24/25, 14:10 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87506

  19. Josua Vogel uploaded patch set 23 V -1 10/24/25, 14:12

  20. Josua Vogel commented on patch set 23 10/24/25, 14:13

    SaveToDatabaseFinisher.php:238 Reply

    Done
  21. core-ci voted on patch set 23 V +1 10/24/25, 14:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87507

  22. Josua Vogel voted on patch set 23 CR +1 V +1 10/24/25, 14:26

  23. Garvin Hicking voted on patch set 23 CR +1 V +1 10/24/25, 14:40

  24. Georg Ringer voted on patch set 23 CR +2 V +2 10/27/25, 18:16

  25. Georg Ringer merged patch set 24 10/27/25, 18:16