mirror of
https://github.com/wger-project/flutter.git
synced 2026-12-02 18:19:25 +01:00
Log.exerciseObj was declared late and is only ever assigned when hydrating the logs of a routine's sessions. Logs read from the database are built through drift's row class and only carry exerciseId, so copyWith threw a LateInitializationError when it unconditionally read the field. Copying a past log in gym mode does exactly that. Make the field nullable behind a getter that throws a descriptive error, add exerciseObjOrNull for callers that legitimately handle logs straight from the database, and only carry the exercise over when there is one. Hydrating the exercise in watchLogsByExerciseDrift instead would mean joining its translations, images, muscles and equipment for every log, which most callers don't need. The log page tests mocked the query with the test routine's logs, which are hydrated, which is why this was never caught. They now return logs without an exercise, like the real query does. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XzxNFoPMxsFPxHD3P2Ma3w