| name | sdk-upgrade-safety |
| description | Ensures SDK changes do not crash or break apps upgrading from older SDK versions. Use when modifying SharedPreferences, Gson/cached models, DTOs, Storage, UserDataSource, cache migration, or any persisted SDK state. Use proactively before finishing SDK persistence or API model changes — not only when the user mentions upgrades.
|
Before finishing changes that touch persistence or serialized models, read: agentdocs/sdkUpgrade.md
Required check
Assume users upgrade the SDK without clearing app data. Verify the change is safe for:
- Cached
ApphudUser and other Gson objects in SharedPreferences
- New or changed preference keys
- Gson DTOs (missing JSON fields on older API responses)
- Disk/cache files and
cacheVersion migrations
Rules
- Never add non-nullable fields without defaults to models that are persisted.
- Prefer new SharedPreferences keys over changing existing JSON shapes.
- Nullable + default for new DTO fields; network-only DTOs are lower risk than cached domain models.
- Fallback when a pref key is missing after upgrade (
null → default URL / empty / re-register).
- Test legacy JSON / missing keys when the change is non-trivial.
Workflow
- Identify what is persisted vs network-only.
- Walk the upgrade path: old SDK data → new SDK read path.
- Add or extend tests if deserialization or storage reads changed.
- Run
./gradlew :sdk:testDebugUnitTest for affected tests.