Review main Ready for review Stale

86437[TASK] Throw custom exception database value decoding

Stefan Bürk CR 0 V 0 Normal +126 −2 updated 08/15/26, 23:24

Commit message

With #100088 TCA type JSON has been introduced on top of the
native JSON field support added shortly before with #99062,
a utility method has been added to easy the proper handling
and decoding of json values back to an array. That has been
bound strictly to the TCA type.

In some cases, invalid data could have been inserted into the
database ending up in a `ValueNotConvertible` exception which
is not handled.

This change rethrows a TYPO3 specific exception with the
timestamp as exception code, naming table, field and uid of
the offending row and adding as previous exception the
doctrine/dbal exception, as this cases needs to be
investigated and fixed in the database.

The offending value is shortened in the message, as it is
unbounded in length and may carry sensitive data. Table,
field and uid identify the row, so the complete value stays
retrievable from the database.

Falling back to some kind of default value or simply logging
the error would change the value and could lead to hard to
hunt bugs and overseeing the entries in the log.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 9
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/37/86437/9 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/37/86437/9 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Merge conflicts 10

Issues 3

Files 3

Review log 1422

  1. Stefan Bürk uploaded patch set 1 10/05/24, 21:55

  2. Stefan Bürk rebased onto patch set 2 10/05/24, 22:05

  3. core-ci voted on patch set 1 V -1 10/05/24, 22:12 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67165

  4. core-ci voted on patch set 2 V +1 10/05/24, 22:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67166

  5. Stefan Bürk updated the commit message in patch set 3 V +1 10/07/24, 07:58

  6. core-ci voted on patch set 3 V +1 10/07/24, 08:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67207

  7. Benjamin Franzke commented on patch set 3 CR -1 10/07/24, 08:29

    BackendUtility.php:3102

    I'm not yet sure whether it's correct to silently ignore invalid database values and interpret them as default value. If at all that should probably be combined with logging. (I'm still not sure whether we should produce a conctete "InvalidDatabaseValue" exception, as we basically "loose" invalid data (and the possibility to analyse it) by falling back to the default value)

    BackendUtility.php:3112

    Why do you convert the default value in line 3107 and then set it again here (without conversion)? Looks like a left-over
  8. Stefan Bürk voted on patch set 3 CR -2 10/07/24, 18:03

  9. Stefan Bürk uploaded patch set 4 CR -1 V +1 10/10/24, 17:18

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  10. Stefan Bürk commented on patch set 3 CR 0 10/10/24, 17:18

    Copied votes on follow-up patch sets have been updated: * Copied Code-Review vote has been removed from patch set 4 (was Code-Review-2) since the new Code-Review=0 vote is not copyable (copy condition: "changekind:NO_CHANGE OR is:MIN").

    BackendUtility.php:3102 Reply

    Than we could just leave the doctrine exception which has that information in the exception message - otherwise we could simply duplicate the same exception along to have a TYPO3 exception code in it. Will add a duplicate for now.
  11. Stefan Bürk updated the commit message in patch set 5 10/10/24, 17:19

  12. core-ci voted on patch set 5 V +1 10/10/24, 17:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67522

  13. core-ci voted on patch set 4 V +1 10/10/24, 17:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67521

  14. Stefan Bürk commented on patch set 5 10/11/24, 13:14

    BackendUtility.php:3102 Reply Unresolved

    Rethrow now a TYPO3 exception to have a code integer at place for documention things. Not sure if that is really a good way. Logging it needs to return something, and could also be breaking than. Not sure if this is now the correct way, but feels to be the less worse option here for now. Change made as to-be discussed.

    BackendUtility.php:3112 Reply

    Removed it.
  15. Oliver Hader updated the commit message in patch set 6 V +1 10/18/24, 13:58

  16. Benni Mack updated the commit message in patch set 7 04/22/26, 06:24

  17. core-ci voted on patch set 7 V -1 04/22/26, 06:28 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100687

  18. Oliver Klee voted on patch set 7 CR +1 04/22/26, 07:42

  19. Stefan Bürk uploaded patch set 8 CR +1 V -1 08/15/26, 20:21

  20. core-ci voted on patch set 8 V +1 08/15/26, 20:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106766

  21. Stefan Bürk uploaded patch set 9 V +1 08/15/26, 23:17

  22. core-ci voted on patch set 9 V +1 08/15/26, 23:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106767