Skip to content

Fix ReflexEvent argument order for client_handler_name in format_event - #7156

Merged
masenf merged 2 commits into
reflex-dev:mainfrom
FarhanAliRaza:farhan/suspicious-bose-dac4f3
Sep 15, 2026
Merged

masenf merged 2 commits into
reflex-dev:mainfrom
FarhanAliRaza:farhan/suspicious-bose-dac4f3

Conversation

@FarhanAliRaza

@FarhanAliRaza FarhanAliRaza commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

format_event() in reflex_base/utils/format.py appended client_handler_name as the third positional argument of ReflexEvent(...), but the JS constructor in .templates/web/utils/state.js is ReflexEvent(name, payload, event_actions, handler) — event_actions is third and handler is fourth.

As a result, for any EventSpec with a non-empty client_handler_name formatted through format_event, the handler string landed in the event_actions slot and e.handler stayed null, so the event.handler === "uploadFiles" routing in applyRestEvent could never fire.

Real-world impact

client_handler_name is set to "uploadFiles" by rx.upload_files / rx.upload_files_chunk specs. Such a spec flows through format_queue_events → format_event when used as:

  • a rx.call_script / rx.call_function callback
  • a toast action / cancel button on_click (or on_dismiss / on_auto_close)

In those contexts the upload would silently never start.

Fix

Emit event_actions (as JSON) third and client_handler_name fourth, matching the already-correct pattern in LiteralEventVar.create. Output for specs without a client_handler_name is byte-identical to before, so no other compiled output changes.

Test

Regression test test_format_event_client_handler_name in tests/units/test_event.py — fails before the fix (handler string in the third slot), passes after.

Review in cubic

…t_event

format_event() appended client_handler_name as the third positional
argument of ReflexEvent, but the JS constructor takes event_actions
third and handler fourth. The handler string landed in event_actions
and e.handler stayed null, so applyRestEvent routing (uploadFiles)
never fired for events formatted through format_queue_events, e.g. an
upload handler used as a call_script/call_function callback or toast
action. Emit event_actions (JSON) third and client_handler_name
fourth, matching LiteralEventVar.create.
@FarhanAliRaza
FarhanAliRaza requested a review from a team as a code owner September 15, 2026 17:31
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-15T17:34:53.173121Z 1b91f15 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The functional fix appears correct, but the explicit repository requirements for test placement, helper docstrings, and changelog wording must be satisfied before merging.

Findings

  1. P2 Formatter test in wrong module ▶
  2. P2 Upload helper lacks required docstring ▶

Summary

Corrects format_event() to emit event actions as the third ReflexEvent argument and the client handler name as the fourth, matching the JavaScript constructor and LiteralEventVar.create.

  • Restores client-handler routing for events formatted through callbacks, including upload events.
  • Preserves existing output for events without a client handler.
  • Adds regression assertions for empty and populated event actions and a package changelog fragment.
  • No behavioral defect was identified; repository-required test organization, helper documentation, and changelog wording need adjustment.

Reviews (1) · Last reviewed commit: "chore: rename news fragment to PR number"

Comment thread tests/units/test_event.py Resolved
Comment thread tests/units/test_event.py Resolved
@codspeed

codspeed Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 40 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing FarhanAliRaza:farhan/suspicious-bose-dac4f3 (1b91f15) with main (6479e2e)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@masenf
masenf merged commit 17825d7 into reflex-dev:main Sep 15, 2026
114 checks passed
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