Skip to content

fix: raise clear error for unserialized properties on dataclass and Pydantic vars - #7648

Open
somiljain2006 wants to merge 6 commits into
reflex-dev:mainfrom
somiljain2006:Serial
Open

somiljain2006 wants to merge 6 commits into
reflex-dev:mainfrom
somiljain2006:Serial

Conversation

@somiljain2006

@somiljain2006 somiljain2006 commented Oct 23, 2026 •

Copy link
Copy Markdown

All Submissions:

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

New Feature Submission:

  • Does your submission pass the tests?
  • Have you linted your code locally prior to submission?

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Description

This change prevents plain Python properties on Pydantic models and dataclasses from being treated as accessible Reflex Vars when those properties are not included in the serialized output. Accessing such properties could generate a frontend reference to a value that does not exist in the serialized object, resulting in undefined at runtime.

The change provides a clear error for unsupported properties while preserving access to declared fields and Pydantic computed_field values. Regression tests cover both Pydantic models and dataclasses.

Closes #7633

View guided diff

@somiljain2006
somiljain2006 requested a review from a team as a code owner October 23, 2026 09:51
@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The latest change appears safe to merge; it preserves the explicit typing.Union regression test.

Summary

The PR rejects plain properties omitted from serialized Pydantic models and dataclasses while preserving computed fields and custom model serializers.

  • State-variable access rejects properties missing from serialized objects.

Reviews (4) · Last reviewed commit: "Update tests/units/vars/test_object.py" · Reviewed by Greptile

Comment thread packages/reflex-base/src/reflex_base/utils/types.py
Comment thread packages/reflex-base/src/reflex_base/vars/object.py Outdated
Comment thread packages/reflex-base/src/reflex_base/vars/object.py Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Re-trigger cubic

Comment thread packages/reflex-base/src/reflex_base/vars/object.py Outdated
Comment thread packages/reflex-base/src/reflex_base/utils/types.py

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread tests/units/vars/test_object.py Outdated
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plain @property on a Pydantic model or dataclass state var compiles but renders empty

1 participant