fix: serialize team_name in StatboticsTeamEvent.toJson - #8
Conversation
StatboticsTeamEvent.fromJson decodes team_name, but toJson left it out, so a record cached through toJson and reloaded through fromJson lost the nickname. The on-device last-good cache round-trips through these two methods, and team_name is the one event-scoped name source (/teams ignores its event parameter), so the loss was silent. Add the field to toJson and two round-trip regression tests. On behalf of @Project516
📝 WalkthroughWalkthroughThe change preserves ChangesTeam name serialization
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
cc @Project516 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@CHANGELOG.md`:
- Around line 5-7: Rewrite the changelog sentence about
StatboticsTeamEvent.toJson and fromJson so it is grammatical and directly states
that toJson serializes team_name and fromJson preserves it during round trips.
Keep the existing context about nickname preservation without adding unrelated
details.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 840a2294-691d-4e1c-9596-adb53ec19265
📒 Files selected for processing (4)
CHANGELOG.mdlib/src/statbotics_models.dartpubspec.yamltest/statbotics_client_test.dart
| - `StatboticsTeamEvent.toJson` now serializes `team_name`, so the | ||
| round-trip `toJson` advertises through `fromJson` actually preserves the | ||
| nickname. Previously the field was decoded but left out of `toJson`, so a |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Correct the malformed round-trip sentence.
Line 6 is not grammatical and does not clearly describe the serialization contract. Use a direct toJson/fromJson statement.
Proposed wording
- `StatboticsTeamEvent.toJson` now serializes `team_name`, so the
- round-trip `toJson` advertises through `fromJson` actually preserves the
+ `toJson`/`fromJson` round trip now preserves the
nickname.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - `StatboticsTeamEvent.toJson` now serializes `team_name`, so the | |
| round-trip `toJson` advertises through `fromJson` actually preserves the | |
| nickname. Previously the field was decoded but left out of `toJson`, so a | |
| - `StatboticsTeamEvent.toJson` now serializes `team_name`, so the | |
| `toJson`/`fromJson` round trip now preserves the | |
| nickname. |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@CHANGELOG.md` around lines 5 - 7, Rewrite the changelog sentence about
StatboticsTeamEvent.toJson and fromJson so it is grammatical and directly states
that toJson serializes team_name and fromJson preserves it during round trips.
Keep the existing context about nickname preservation without adding unrelated
details.
Problem
StatboticsTeamEvent.fromJsondecodesteam_name, buttoJsonleft the field out. ThetoJsondoc comment claims the model "round-trips throughfromJsonfor the on-device last-good cache," and the README says models "round-trip throughtoJsonfor caching," so a cached record that survives a relaunch comes back with an emptyteamNameeven though/team_eventshad carried one.team_nameis the one event-scoped name source:/teamsaccepts aneventparameter and ignores it, answering with the global team list. So the loss is silent and the nickname cannot be recovered from any other endpoint thatStatboticsClientexposes.Repro
Fix
Add
'team_name': teamNametoStatboticsClient(well,lib/src/statbotics_models.dart)toJson, and two round-trip regression tests: one with a nickname, one empty. The empty-name test passes before the fix; the nickname test does not, and it guards the field going forward.dart analyzeis clean and the full suite passes (25 tests).Only
team_namewas at risk; every other field intoJsonalready round-tripped, so the added test also asserts the rest of the model.On behalf of @Project516
Summary by CodeRabbit
Bug Fixes
Chores