Skip to content
This repository was archived by the owner on Oct 2, 2026. It is now read-only.

Fix update_dataclass_from_json for None/frozen nested dataclasses - #1403

Merged
richard-to merged 1 commit into
mainfrom
claude/issue-1401-fix-mu5gcc
Sep 18, 2026
Merged

richard-to merged 1 commit into
mainfrom
claude/issue-1401-fix-mu5gcc

Conversation

@richard-to

Copy link
Copy Markdown
Collaborator

_recursive_update_dataclass_from_json_obj rebuilt a nested dataclass field
by recursing into whatever the attribute currently held. That breaks for a
field typed X | None holding None (nothing to recurse into, raises
"Unhandled stateclass deserialization") and for a frozen nested dataclass
(setattr raises FrozenInstanceError). Both cases surface inside
update_state, before any event handler runs, so the interaction silently
does nothing.

Build nested dataclass values (including list items) directly from the
JSON payload via the constructor, resolving X | None to X from the
type hint, instead of instantiating empty and mutating with setattr.

Fixes #1401

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_019XKNGzaycAUrysh8HgHpPX

_recursive_update_dataclass_from_json_obj rebuilt a nested dataclass field
by recursing into whatever the attribute currently held. That breaks for a
field typed `X | None` holding `None` (nothing to recurse into, raises
"Unhandled stateclass deserialization") and for a frozen nested dataclass
(setattr raises FrozenInstanceError). Both cases surface inside
update_state, before any event handler runs, so the interaction silently
does nothing.

Build nested dataclass values (including list items) directly from the
JSON payload via the constructor, resolving `X | None` to `X` from the
type hint, instead of instantiating empty and mutating with setattr.

Fixes #1401

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019XKNGzaycAUrysh8HgHpPX

Copy link
Copy Markdown
Collaborator Author

The test check failure is a single Playwright e2e timeout in mesop/components/box/e2e/box_events_test.ts:18 ("test right click event"), waiting on getByText('Is Click: True'). This is unrelated to this PR's change (mesop/dataclass_utils/dataclass_utils.py and its test file only) — CI is green on the base commit (main @ 9ca3b56), and this test doesn't touch anything in the diff. It looks like a timing flake in an unrelated component.

I don't have permission to trigger a re-run from here (got a 403 on the rerun-failed-jobs API). Flagging so a maintainer can re-run the job; I'll keep watching this PR for further CI/review activity.


Generated by Claude Code

@richard-to
richard-to merged commit 6b404d2 into main Sep 18, 2026
5 of 6 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update_dataclass_from_json cannot rebuild a nested dataclass that is None, or one that is frozen

2 participants