Skip to content

Fix crash on Category rows with NULL/degenerate localized_name - #695

Merged
troymyree-lang merged 2 commits into
mainfrom
feature/694/fix-null-category-name-crash
Aug 28, 2026
Merged

Fix crash on Category rows with NULL/degenerate localized_name#695
troymyree-lang merged 2 commits into
mainfrom
feature/694/fix-null-category-name-crash

Conversation

@troymyree-lang

Copy link
Copy Markdown
Collaborator

Summary

  • Adds MIGRATION_7_8 to repair legacy Category rows whose localized_name is a genuine SQL NULL (from MIGRATION_3_4's "My Sayings" insert) — Room's generated read path for a non-null field throws IllegalStateException before any type converter runs, so this has to be fixed at the data layer, not the converter.
  • Adds Converters.languagesWithTextToStringMapNonNull as a defensive fallback for the related but distinct case of a non-null-but-degenerate value (the literal string "null", produced by a Kotlin string-interpolation bug in MIGRATION_5_6).
  • Adds regression tests for both cases.

Ticket

Closes #694

Type of Change

  • Bug fix
  • Tests

Testing

  • Unit tests added/updated
  • Integration tests added/updated (MigrationTest.migrate7to8_repairsNullLocalizedName, RoomStoredCategoriesRepositoryTest)
  • Manual testing performed — no local emulator available in this environment; androidTest additions compile cleanly (./gradlew :app:compileDebugAndroidTestKotlin) and will run via this repo's Firebase Test Lab CI

Checklist

  • Tests pass locally (./gradlew testDebug)
  • No API keys or secrets in code
  • CLAUDE.md updated (if new pattern introduced) — no new pattern, matches existing migration/converter conventions; see Documentation/work-log/694-fix-null-category-name-crash.md for full investigation notes

Room's non-null field read path throws IllegalStateException on a genuine
SQL NULL before any type converter runs, so the fix is a data-repair
migration (v7->v8) plus a defensive converter fallback for the related
non-null-but-degenerate case a legacy migration bug can produce.

Closes #694
…hema-enforced one

Room's 6->7 auto-migration does a full table rebuild that enforces NOT NULL,
so a genuine SQL NULL can never actually survive today's migration path --
confirmed by CI rejecting the original test's insert with a
SQLiteConstraintException. Rewrote the MIGRATION_7_8 test to seed a
physically-drifted table directly instead of through Room's schema-enforced
helper. Also fixes a collateral break in the pre-existing migrate5to6 test
caused by the DB version bump.
@troymyree-lang
troymyree-lang merged commit fd42d83 into main Aug 28, 2026
4 checks passed
@troymyree-lang
troymyree-lang deleted the feature/694/fix-null-category-name-crash branch August 28, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash: IllegalStateException in CategoryDao_Impl.getAllCategoriesFlow on rows with NULL localized_name

1 participant