Commit 6e99c83
committed
fix(reviver): make from_json idempotent for object_hook use
Codex identified that ``json.loads(..., object_hook=reviver)`` revives
nested dicts bottom-up, so by the time ``ThreadImpl.from_json`` runs,
a payload's ``currentMessage`` is already a ``Message`` instance, not a
dict. The old code then called ``Message.from_json(current_msg_raw)``
on that Message, which raised ``AttributeError`` on ``.get`` and broke
deserialization of any serialized thread containing a currentMessage.
Fix:
- ``Message.from_json`` returns ``data`` unchanged if it's already a Message
- ``ThreadImpl.from_json`` / ``ChannelImpl.from_json`` do the same, plus
pass the (possibly already-Message) ``currentMessage`` through the
now-idempotent ``Message.from_json``
- Regression test exercises the exact object_hook bottom-up path with a
nested currentMessage
Also moved ``TestStandaloneReviver``'s per-method local imports to the
module top level per gemini-code-assist review (PEP 8 E402).
https://claude.ai/code/session_01XE1bMoQ5BjCvgi1iLGKKhG1 parent 0ff1703 commit 6e99c83
4 files changed
Lines changed: 79 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
400 | | - | |
| 400 | + | |
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
| |||
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
414 | 418 | | |
| 419 | + | |
| 420 | + | |
415 | 421 | | |
416 | 422 | | |
417 | 423 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
739 | 739 | | |
740 | 740 | | |
741 | 741 | | |
742 | | - | |
| 742 | + | |
743 | 743 | | |
744 | 744 | | |
745 | 745 | | |
| |||
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
758 | 762 | | |
| 763 | + | |
| 764 | + | |
759 | 765 | | |
760 | | - | |
761 | | - | |
762 | | - | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
763 | 769 | | |
764 | 770 | | |
765 | 771 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
439 | | - | |
| 439 | + | |
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
446 | 452 | | |
| 453 | + | |
| 454 | + | |
447 | 455 | | |
448 | 456 | | |
449 | 457 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
18 | | - | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| |||
877 | 880 | | |
878 | 881 | | |
879 | 882 | | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | 883 | | |
885 | 884 | | |
886 | 885 | | |
| |||
907 | 906 | | |
908 | 907 | | |
909 | 908 | | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
914 | 909 | | |
915 | 910 | | |
916 | 911 | | |
| |||
950 | 945 | | |
951 | 946 | | |
952 | 947 | | |
953 | | - | |
954 | | - | |
955 | | - | |
956 | | - | |
957 | 948 | | |
958 | 949 | | |
959 | 950 | | |
| |||
1000 | 991 | | |
1001 | 992 | | |
1002 | 993 | | |
1003 | | - | |
1004 | | - | |
1005 | 994 | | |
1006 | 995 | | |
1007 | 996 | | |
| |||
1015 | 1004 | | |
1016 | 1005 | | |
1017 | 1006 | | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
1021 | | - | |
1022 | 1007 | | |
1023 | 1008 | | |
1024 | 1009 | | |
| |||
1055 | 1040 | | |
1056 | 1041 | | |
1057 | 1042 | | |
1058 | | - | |
1059 | | - | |
1060 | 1043 | | |
1061 | 1044 | | |
1062 | 1045 | | |
| |||
1072 | 1055 | | |
1073 | 1056 | | |
1074 | 1057 | | |
1075 | | - | |
1076 | | - | |
1077 | | - | |
1078 | 1058 | | |
1079 | 1059 | | |
1080 | 1060 | | |
| |||
1088 | 1068 | | |
1089 | 1069 | | |
1090 | 1070 | | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
1091 | 1120 | | |
1092 | 1121 | | |
1093 | 1122 | | |
| |||
0 commit comments