CATROID-1654 Fix startup crash by hardening project parsing and room upgrade#5203
Conversation
There was a problem hiding this comment.
Pull request overview
Hardens legacy code.xml project metadata parsing to prevent app startup crashes when encountering malformed or corrupted project metadata after upgrades.
Changes:
- Added unit tests for invalid/missing
programNamehandling in legacy metadata parsing. - Updated
ProjectMetaDataParserto validateprogramNameand normalize runtime parsing failures intoIOException. - Updated startup project scan in
MainFragmentViewModelto skip/log projects whose metadata cannot be parsed (including file path in logs).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
catroid/src/test/java/org/catrobat/catroid/test/content/backwardcompatibility/ProjectMetaDataParserTest.java |
Adds regression tests for invalid metadata inputs (missing/blank programName). |
catroid/src/main/java/org/catrobat/catroid/ui/recyclerview/viewmodel/MainFragmentViewModel.kt |
Hardens startup scan by catching parsing failures and logging the failing metadata path. |
catroid/src/main/java/org/catrobat/catroid/content/backwardcompatibility/ProjectMetaDataParser.java |
Adds validation for required fields and wraps runtime XStream parse failures into IOException. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I investigated the device crash log from the update-repro setup and found a second startup crash that is separate from the project XML parsing fix. Root cause from logcat:
This happens in I pushed a follow-up on this PR branch:
This migration only rebuilds synced/cache data tables, not user projects, so it should prevent startup crash on update without requiring full app data deletion. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… entries makes the tests green
e07f75f to
6bdaadf
Compare
|
I confirmed the crash before the fix consistently on my phone, then updated to the fixed version (with the same package name) and observed no crash anymore. I also tested the fixed APK along other aspects and found no obvious deficiencies. |
reichli
left a comment
There was a problem hiding this comment.
I only found one problem with a test that I could not run.
The rest of the PR looks good! Database migration + tests look good.
I was also able to reproduce the crash and fix it with this PR.
|
reichli
left a comment
There was a problem hiding this comment.
Approved - thank you very much!



Summary
This PR prevents startup crashes after app updates in two related startup paths:
code.xml)https://catrobat.atlassian.net/browse/CATROID-1654
What changed
Added regression tests for invalid metadata parsing in
ProjectMetaDataParserTest.Hardened
ProjectMetaDataParserto:programNameIOExceptionconsistentlyHardened startup project scan in
MainFragmentViewModel:IOException)Added Room database upgrade handling for featured-project cache data:
AppDatabaseversion2 -> 3MIGRATION_2_3and wired it in Koin database builderfeatured_project,project_response,project_category)3.jsonWhy
On upgraded installs with legacy/corrupted project metadata, startup scan could fail before the user reaches the main UI.
Additionally, some upgraded installs had a legacy Room identity hash (
c60ebf...) while current code expects (2d6dd...), causing startup termination when opening the featured-project cache DB.Behavior after fix
App startup remains stable even if one or more project metadata files are broken.
Broken project metadata entries are skipped; valid projects still load.
Featured-project cache DB is migrated/rebuilt on upgrade without deleting user projects.
Testing
:catroid:testCatroidDebugUnitTest --tests "org.catrobat.catroid.test.content.backwardcompatibility.ProjectMetaDataParserTest" --no-daemon
:catroid:testCatroidDebugUnitTest --tests "org.catrobat.catroid.test.content.backwardcompatibility.*" --no-daemon
:catroid:testCatroidDebugUnitTest --tests "org.catrobat.catroid.db.DatabaseMigrationsTest" --no-daemon
Your checklist for this pull request
Please review the contributing guidelines and wiki pages of this repository.