Skip to content

fix(base): preserve typed serialization results for dataclasses - #7699

Open
DevChiniwala wants to merge 2 commits into
reflex-dev:mainfrom
DevChiniwala:fix/dataclass-serializer-result-type
Open

DevChiniwala wants to merge 2 commits into
reflex-dev:mainfrom
DevChiniwala:fix/dataclass-serializer-result-type

Conversation

@DevChiniwala

@DevChiniwala DevChiniwala commented Oct 31, 2026 •

Copy link
Copy Markdown

serialize(value, get_type=True) promises a (serialized_value, type) pair, but the fallback for dataclass instances returns only the fields dictionary. Unpacking fails for zero, one, or more than two fields; with exactly two fields it silently unpacks the dictionary's keys instead of returning the serialized value and type.

Return the fields dictionary together with dict when type information is requested. The default serialization result stays the same, and explicitly registered serializers retain their precedence and declared output type.

Validation on Linux / Python 3.14 for 911c38d970d4e45b3b1723066b4883195e538d3d:

  • Current-main control: eight failing dataclass cases and one passing registered-serializer control; all nine pass with the fix.
  • Related serializer suites: 125 passed, 1 skipped.
  • All eight applicable configured presubmit hooks pass: Ruff format/lint, codespell, stub generation, Pyright, ty, and the Python 3.11/3.14 type-check examples.
  • The all-hooks bootstrap encounters a nodeenv prerelease-version parsing error when provisioning non-applicable Biome. Applicable hooks were run individually with the unchanged repository configuration; Biome has no matching files in this PR.
  • The merge conflict keeps upstream ORM serializer tests byte-for-byte and puts the nine core dataclass cases in a separate module, avoiding its optional SQLAlchemy module skip.
  • The reflex-base news fragment remains included. No generated stubs, dependency changes or unrelated product changes are authored.

Hosted checks on the new head require maintainer approval; no full-repository or current-head hosted success is claimed. AI assistance: OpenAI Codex.

All Submissions

  • Checked the contribution guidelines and reviewed the patch.
  • Checked for competing open PRs for this return-shape bug.

Type of change

  • Bug fix.

Changes To Core Features

  • Explained the changed behavior and why it matters.
  • Added regression tests and ran related tests locally.

View guided diff

Copilot AI balanced review requested due to automatic review settings October 31, 2026 10:11
@DevChiniwala
DevChiniwala requested a review from a team as a code owner October 31, 2026 10:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@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.

No issues found across 3 files

View guided diff | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Fixes serialize(value, get_type=True) for dataclasses without a registered serializer.

  • Dataclass serialization returns its output type when callers ask.

No actionable issues found. Tests were inspected but not run during this review.

Reviews (2) · Last reviewed commit: "fix(base): reconcile dataclass serialize..." · Reviewed by Greptile

@DevChiniwala

Copy link
Copy Markdown
Author

Synced current main in 911c38d970d4e45b3b1723066b4883195e538d3d. The test-path conflict is resolved by preserving upstream's ORM serializer tests unchanged and keeping the nine dataclass regressions in a separate module. The core regression tests therefore remain independent of the ORM module's optional SQLAlchemy skip.

Validation on Linux / Python 3.14:

  • The current-main control has eight failing dataclass cases and one passing registered-serializer control; all nine pass with the fix.
  • All 125 related serializer tests pass, with one existing skip.
  • All eight applicable configured hooks pass, including Ruff, codespell, stub generation, Pyright, ty, and the Python 3.11/3.14 type examples. The all-hooks bootstrap hits a nodeenv prerelease-version parsing error while provisioning non-applicable Biome; the applicable hooks were run individually with the unchanged repository configuration.

The pushed tree is limited to the serializer fix, its regression module and the existing news fragment. Hosted validation on this new commit still needs maintainer workflow approval.

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.

2 participants