Skip to content

Commit c24a249

Browse files
committed
fix(models): read legacy doctype_meta_modifed_at key as a fallback
M6 (round 2): MobileFormName.fromJson falls back to the previously-misspelled doctype_meta_modifed_at key when the corrected doctype_meta_modified_at is absent, so any payload or replayed response still emitting the typo keeps working. No persistence migration is needed (toJson has no callers); this is pure read-side defense-in-depth.
1 parent 380cdac commit c24a249

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

lib/src/models/mobile_form_name.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ class MobileFormName {
1616
return MobileFormName(
1717
mobileDoctype: json['mobile_workspace_item'] as String? ?? '',
1818
groupName: json['group_name'] as String?,
19-
doctypeMetaModifiedAt: json['doctype_meta_modified_at'] as String?,
19+
// Read-only fallback to the previously-misspelled key so any payload
20+
// (or older cached/replayed response) still emitting the typo keeps
21+
// working. MobileFormName is never persisted (toJson has no callers), so
22+
// no kv migration is needed — this is pure defense-in-depth.
23+
doctypeMetaModifiedAt:
24+
json['doctype_meta_modified_at'] as String? ??
25+
json['doctype_meta_modifed_at'] as String?,
2026
doctypeIcon: json['doctype_icon'] as String?,
2127
);
2228
}

test/models/mobile_form_name_test.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,27 @@ void main() {
2626
},
2727
);
2828

29+
test(
30+
'fromJson reads the legacy misspelled key as a fallback (M6)',
31+
() {
32+
// A payload still emitting the old `doctype_meta_modifed_at` typo must
33+
// still populate doctypeMetaModifiedAt; the corrected key wins when both
34+
// are present.
35+
final legacyOnly = MobileFormName.fromJson({
36+
'mobile_workspace_item': 'X',
37+
'doctype_meta_modifed_at': '2026-02-02',
38+
});
39+
expect(legacyOnly.doctypeMetaModifiedAt, '2026-02-02');
40+
41+
final both = MobileFormName.fromJson({
42+
'mobile_workspace_item': 'X',
43+
'doctype_meta_modified_at': '2026-03-03',
44+
'doctype_meta_modifed_at': '2026-02-02',
45+
});
46+
expect(both.doctypeMetaModifiedAt, '2026-03-03');
47+
},
48+
);
49+
2950
test('toJson round-trips all fields', () {
3051
const m = MobileFormName(
3152
mobileDoctype: 'Attendance',

0 commit comments

Comments
 (0)