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

SO
14h ago
+278-16

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