Review main Merged

79585[BUGFIX] Do not return exit codes > 255

Andreas Kienast CR +2 V +2 Easy +4 −0 updated 07/03/23, 10:58

Commit message

If a console command throws an exception that isn't caught, the exit
code evaluates to "0" (aka successful) because the exit codes usually
are the exception timestamp and UNIX doesn't support exit codes > 255.

The issue is now solved by checking the exit code in
`CommandApplication` and setting an upper bound of 255.

Review

  • Code review CR +2 Done
    • Andreas Kienast +2
    • Jochen Roth +1
    • Markus Klein +1
    • Stefan Bürk +1
    • Susi Moog +1
  • Verified V +2 Done
    • Andreas Kienast +2
    • Jochen Roth +1
    • Markus Klein +1
    • Stefan Bürk +1
    • Susi Moog +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 1517

  1. Andreas Kienast uploaded patch set 1 07/03/23, 10:31

  2. Markus Klein commented on patch set 2 07/03/23, 10:32

    Published edit on patch set 1.
  3. Markus Klein commented on patch set 2 V +1 CR +1 07/03/23, 10:33

    I added a comment explaining the condition
  4. Susi Moog voted on patch set 2 V +1 CR +1 07/03/23, 10:33

  5. Mathias Brodala commented on patch set 1 07/03/23, 10:33

    CommandApplication.php:113

    IMO this should at least trigger another error message. Otherwise this is silently skipped and makes debugging harder.
  6. Andreas Kienast commented on patch set 2 07/03/23, 10:35

    CommandApplication.php:113 Reply

    I'm replicating Symfony behavior here, please see https://github.com/symfony/console/blob/6.3/Application.php#L207-L213.
  7. Stefan Bürk voted on patch set 2 V +1 CR +1 07/03/23, 10:37

  8. Mathias Brodala commented on patch set 2 07/03/23, 10:37

    CommandApplication.php:113 Reply

    Added here: https://github.com/symfony/console/commit/a60cde753cc946f88325b4c13dd53ca0a490c42c Still I'd prefer doing it better than Symfony here.
  9. core-ci voted on patch set 1 V +1 07/03/23, 10:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43209

  10. core-ci voted on patch set 2 V +1 07/03/23, 10:41 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43210

  11. Andreas Kienast commented on patch set 2 07/03/23, 10:42

    CommandApplication.php:113 Reply

    How should that look like? A new message in the console that the thrown exception code was converted to 255? I think I'd -1 this.
  12. Mathias Brodala commented on patch set 2 07/03/23, 10:44

    CommandApplication.php:113 Reply

    Almost. An error message that a return code > 255 was detected including the return code and that it is normalized to 255. That's enough information to trace back the behavior. At least I'd be very glad for these details.
  13. Jochen Roth voted on patch set 2 V +1 CR +1 07/03/23, 10:45

  14. Susi Moog commented on patch set 2 07/03/23, 10:45

    CommandApplication.php:113 Reply

    In this case, I would not even expect to get the exitCode from the exception as bash exception code. The core (non-symfony) cli exception handler hardcodes this to one in this case. I think it's totally fine to use 255 here for exceptions (that are not otherwise handled). In which case do you think this makes thinks harder?
  15. Mathias Brodala commented on patch set 2 07/03/23, 10:51

    CommandApplication.php:113 Reply

    Mostly in case someone (semi-)intentionally uses codes > 255 and wonders why his command does not exit with that code. But you are right, right now this is silently normalized to 0, silently normalizing this to 255 is already and improvement.
  16. Andreas Kienast voted on patch set 2 V +2 CR +2 07/03/23, 10:58

  17. Andreas Kienast merged patch set 3 07/03/23, 10:58