Skip to content

fix: read model_fields once when filtering rx.Model event args - #7636

Merged
FarhanAliRaza merged 1 commit into
reflex-dev:mainfrom
fixfon:fix/7634-model-fields-event-arg
Oct 23, 2026
Merged

FarhanAliRaza merged 1 commit into
reflex-dev:mainfrom
fixfon:fix/7634-model-fields-event-arg

Conversation

@fixfon

@fixfon fixfon commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

  • Bug fix (non-breaking change which fixes an issue)

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

_transform_event_arg drops non-field keys from a dict payload hinted as an rx.Model. It checked each key against hinted_args.__fields__, which Pydantic v2 deprecates, so every key of every event emitted a PydanticDeprecatedSince20 warning. It now reads hinted_args.model_fields once before filtering. The filtering behaviour is unchanged.

This touches a different call site than #7592, which covers reflex_base/utils/types.py. The two PRs don't overlap.

closes #7634

Verification

  • New unit test test_transform_event_arg_model_drops_non_fields_without_deprecation. It asserts that no PydanticDeprecatedSince20 is emitted, that the field values are kept, and that the extra keys are dropped (model_extra is empty; rx.Model uses extra="allow", so the test fails if the filter is removed). The test fails on main and passes with this change.
  • tests/units/reflex_base/event/processor/test_base_state_processor.py: 156 passed.
  • ruff format --check, ruff check and codespell pass on the changed files.
  • Not run: pyright, ty, biome, the integration tests and the full unit suite.

A towncrier news fragment is included (packages/reflex-base/news/+model-event-arg-fields.bugfix.md).

View guided diff

Event arguments hinted as an rx.Model dropped non-field payload keys by
checking each key against `__fields__`, which Pydantic v2 deprecates, so
every key emitted a PydanticDeprecatedSince20 warning on every event.
Read `model_fields` once before filtering instead.

Closes reflex-dev#7634
@fixfon
fixfon requested a review from a team as a code owner October 22, 2026 18:28
@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Reads model_fields once when converting event arguments hinted as rx.Model, replacing deprecated __fields__ access.

  • Model event arguments stop warning while extra keys are dropped.

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

Reviews (1) · Last reviewed commit: "fix: read model_fields once when filteri..." · Reviewed by Greptile

@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

@masenf masenf added the on deck PRs lined up to review / merge next label Oct 23, 2026
@codspeed

codspeed Bot commented Oct 23, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 5.78%

1 warning

⚠️ 21 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

❌ 1 regressed benchmark
✅ 147 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_state_access[get_handler] 72.9 ms 77.4 ms -5.78%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fixfon:fix/7634-model-fields-event-arg (96e102c) with main (74bcd8b)

Open in CodSpeed

@FarhanAliRaza
FarhanAliRaza merged commit 114312a into reflex-dev:main Oct 23, 2026
171 of 172 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

on deck PRs lined up to review / merge next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rx.Model event arguments emit PydanticDeprecatedSince20 once per payload key

3 participants