Review main Merged

97201[BUGFIX] Respect error code when determining sys_log level

Johannes Kasberger CR +2 V +2 Normal +73 −4 updated 10/30/26, 21:27

Commit message

The log level written to sys_log was derived from the log type only,
so a failed SQL query (type DB, error SYSTEM_ERROR) ended up as "info".

Type::toLevel() now also takes the error code into account. The error
code can only raise the level of the type, never lower it:

- MESSAGE         -> level of the type (unchanged)
- USER_ERROR      -> warning
- SYSTEM_ERROR    -> error
- SECURITY_NOTICE -> notice
- WARNING         -> warning

USER_ERROR is mapped to "warning" on purpose: it is used at many call
sites for user-caused refusals such as missing permissions, which is
documented as "warning (user problem)". Mapping it to "error" would
flood the "at least error" filter and monitoring setups with routine
permission denials.

Review

  • Code review CR +2 Done
    • Oli Bartsch +2
    • Wouter Wolters +1
  • Verified V +2 Done
    • Oli Bartsch +2
    • Wouter Wolters +1

Issues 1

Files 4

Review log 1115

  1. Johannes Kasberger uploaded patch set 1 10/28/26, 16:03

  2. core-ci voted on patch set 1 V +1 10/28/26, 16:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112737

  3. Markus Klein updated the commit message in patch set 2 V +1 10/28/26, 16:45

  4. Markus Klein voted on patch set 2 CR +1 V +1 10/28/26, 16:46

  5. core-ci voted on patch set 2 V +1 10/28/26, 16:54 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112742

  6. Oli Bartsch commented on patch set 2 10/28/26, 21:11

    Hey, thanks for the patch! Works well, I added two comments regarding the error level matching and missing test.

    Type.php:62

    Please map `USER_ERROR` to `LogLevel::WARNING` instead of `error`. It's used at >100 call sites for user-caused refusals such as missing permissions, and belog already shows a warning icon for errors. `LogEntryRepository.php` also calls it "warning (user problem)". Otherwise the "at least error" filter fills up with routine permission denials, and setups monitoring `level = 'error'` would see a jump in volume. Keep `SYSTEM_ERROR` as `error` and `WARNING` as `warning`, and please explain the mapping in the commit message. If you prefer `error` for `USER_ERROR`, we should fix the docblock as well.

    Type.php:92

    Could you please add a unit test, since this is a pure static function. A data provider covering these cases would pin the mapping and the "only raise, never lower" rule, like `DB` + `MESSAGE` => `info`, `DB` + `SYSTEM_ERROR` => `error`, etc.
  7. Johannes Kasberger uploaded patch set 3 CR +1 V +1 10/30/26, 11:56

  8. Johannes Kasberger commented on patch set 3 10/30/26, 12:00

    Reply

    Both changes are added. I think I would be surprised to learn that USER_ERRORS are logged as a warning but since this type is used so often it would be also not great to get so many errors.

    Type.php:62 Reply

    Done

    Type.php:92 Reply

    Done
  9. core-ci voted on patch set 3 V +1 10/30/26, 12:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112869

  10. Oli Bartsch updated the commit message in patch set 4 V +1 10/30/26, 21:17

  11. Oli Bartsch commented on patch set 4 CR +1 V +1 10/30/26, 21:17

    Reply

    Acknowledged
    Hey, thanks again for your patch! Works great. Just removed v13 as this is not considered a priority bugfix.
  12. Wouter Wolters voted on patch set 4 CR +1 V +1 10/30/26, 21:25

  13. Oli Bartsch voted on patch set 4 CR +2 V +2 10/30/26, 21:26

  14. Oli Bartsch merged patch set 5 10/30/26, 21:26

  15. core-ci voted on patch set 4 V +1 10/30/26, 21:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112911