Skip to content

Point to repr() for printed backend vars; skip the storage factory check at runtime - #7818

Merged
FarhanAliRaza merged 2 commits into
mainfrom
fix/backend-var-str-hint-and-storage-factory
Nov 11, 2026
Merged

FarhanAliRaza merged 2 commits into
mainfrom
fix/backend-var-str-hint-and-storage-factory

Conversation

@masenf

@masenf masenf commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Found in the reflex 0.11.0a1 pre-release testing (FINDING-037, FINDING-038).

These are two small client-vars fix-ups, one commit each. They touch separate files and can be split into two PRs if you prefer.

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

FINDING-037: printing a class-level backend var in server code. Since #7651, Field.__str__ raises BackendVarFormatError. So print(State._secret), str(), "%s" % and logging of a class-level backend var or mixin field in server code raise too, and the message only talks about the UI. This change keeps the behaviour (it is intentional) and makes two additions:

  • Field._no_frontend_var_error now ends every variant of the message with "To print or log the field itself in server code, use repr()."
  • The unreleased fix: raise BackendVarFormatError when a backend var is used in the UI #7651 fragment (packages/reflex-base/news/+backend-var-literal-var.bugfix.md) now says that print() and logging in server code are affected and to use repr() there.

FINDING-038: extra default_factory calls. The compile calls a str-compatible default_factory to reject one that produces browser storage (#7582). _shared_storage_groups reruns _compile_client_storage_recursive in each backend worker's first event (hydrate_and_load → _sync_shared_storage), so every such factory ran once more per worker. _compile_client_storage_field and _compile_client_storage_recursive now take a keyword check_factory / check_factories (default True), and the runtime path passes False. The compile still runs the check, so the one extra call per compile stays, as agreed.

Tests

  • tests/units/reflex_base/vars/test_base.py::test_field_format_error_suggests_repr (backend, mixin, state-var field and unbound field): str(field) raises a message that ends with the repr() hint, and repr(field) still works. It fails before the change.
  • tests/units/test_state.py::test_shared_storage_groups_do_not_call_default_factories: a counting factory on str and str | None vars is not called by _shared_storage_groups, and the shared-name groups are unchanged. Before the change, the factory was called twice.
  • uv run pytest tests/units --cov passes (81.4% coverage; tests/units/reflex_bench/drivers/test_browser.py was skipped because Chromium is not installed here). ruff check, ruff format and pyright reflex tests are clean.

Generated by Claude Code

View guided diff Turn on auto-fix

Since #7651, `str()` of a class-level backend var such as `State._secret`
raises `BackendVarFormatError`, so `print()`, `%` formatting and logging of
it in server code raise too, with a message that only talks about the UI.
The error now ends with how to inspect the field there, and the unreleased
#7651 changelog entry says that print and logging are affected.

Found in the reflex 0.11.0a1 pre-release testing (FINDING-037).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dxjadq3qkhKnqZR2b9WBFi
The compile calls a str-compatible `default_factory` to reject one that
produces browser storage. `_shared_storage_groups` reran the same compile
step in every backend worker's first event, calling each such factory once
more per worker. The runtime path now skips the factory call; the compile
still checks.

Found in the reflex 0.11.0a1 pre-release testing (FINDING-038).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dxjadq3qkhKnqZR2b9WBFi
@masenf
masenf requested a review from a team as a code owner November 11, 2026 09:33
@masenf masenf added this to the v0.11.0 milestone Nov 11, 2026
@masenf masenf added the on deck PRs lined up to review / merge next label Nov 11, 2026
@greptile-apps

greptile-apps Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no actionable issues were found.

Summary

This PR adds clearer advice for printing fields and avoids extra factory calls during backend events.

  • Backend field errors now point server code to repr() for printing or logging.
  • Shared-storage grouping no longer calls string-compatible default factories at runtime.

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

Reviews (2) · Last reviewed commit: "Skip the storage default_factory check o..." · 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.

All reported issues were addressed across 7 files

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

View guided diff | Turn on auto-fix | Re-trigger cubic

@codspeed

codspeed Bot commented Nov 11, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 5.05%

2 warnings

⚠️ 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

⚠️ 2 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

❌ 2 regressed benchmarks
✅ 149 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_route_matching[1000] 47.8 µs 50.7 µs -5.72%
❌ test_process_event_burst_independent_tokens[1] 2.7 ms 2.8 ms -4.38%

Tip

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


Comparing fix/backend-var-str-hint-and-storage-factory (b156cf9) with main (2d71015)

Open in CodSpeed

@masenf

masenf commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

On the CodSpeed report: test_route_matching[1000] (−5.7%) and test_process_event_burst_independent_tokens[1] (−4.4%) are both flagged "ran on different hardware" and show the same drift on every open PR this morning. This PR touches neither route matching nor event processing. The only runtime change is that _shared_storage_groups stops calling default_factorys, which removes work.


Generated by Claude Code

@FarhanAliRaza
FarhanAliRaza merged commit 10dd495 into main Nov 11, 2026
169 of 171 checks passed
@FarhanAliRaza
FarhanAliRaza deleted the fix/backend-var-str-hint-and-storage-factory branch November 11, 2026 13:45
masenf added a commit that referenced this pull request Nov 11, 2026
…eck at runtime (#7818)

* Point to repr() when a backend var field is printed in server code

Since #7651, `str()` of a class-level backend var such as `State._secret`
raises `BackendVarFormatError`, so `print()`, `%` formatting and logging of
it in server code raise too, with a message that only talks about the UI.
The error now ends with how to inspect the field there, and the unreleased

Found in the reflex 0.11.0a1 pre-release testing (FINDING-037).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dxjadq3qkhKnqZR2b9WBFi

* Skip the storage default_factory check on the runtime path

The compile calls a str-compatible `default_factory` to reject one that
produces browser storage. `_shared_storage_groups` reran the same compile
step in every backend worker's first event, calling each such factory once
more per worker. The runtime path now skips the factory call; the compile
still checks.

Found in the reflex 0.11.0a1 pre-release testing (FINDING-038).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dxjadq3qkhKnqZR2b9WBFi

---------

Co-authored-by: Claude <[email protected]>
(cherry picked from commit 10dd495)
@masenf masenf added the release-train Issues found during agentic /prerelease-testing fanout, not necessarily validated bugs. label Nov 11, 2026
masenf added a commit that referenced this pull request Nov 12, 2026
* Materialize changelogs for [email protected] (new-prerelease-minor)

* Materialize changelogs for [email protected], [email protected], [email protected] (new-prerelease-minor)

* Materialize changelogs for [email protected], [email protected], [email protected], [email protected] (new-prerelease-patch)

* Materialize changelogs for [email protected] (new-prerelease-minor)

* Carry the train's changelog edits for fragments changed after 0.11.0a1

#7818, #7816, #7800, #7806 and #7799 edited news fragments that the
0.11.0a1 materialization had already consumed. On the release train
(r/pre-2026.11.11) those edits were folded into the matching 0.11.0a1
CHANGELOG.md entries when the fixes were cherry-picked; this carries the
same edits to main, where the fragments are consumed by the
materialization commits above.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dxjadq3qkhKnqZR2b9WBFi

* Tidy the 0.11.0a1 changelog sections

Dedupe entries that appeared in both reflex and reflex-base (SetVar,
@rx.event, rx.client_state, awaitable handlers, foreach hooks, lazy
libraries, blocking detection) and in reflex-components-core (foreach over
set vars), keeping one entry in the reflex changelog. Merge entries for the
same change: deploy_url default with the CORS change, React Compiler with
auto_memoize, the reflex run shutdown and --json entries, the backend-var
errors, the db page-evaluation fixes, and the Redis cancelled-handler fixes.

Drop entries that fix features new in this alpha (blocking-monitor report,
array ref names, middleware on awaited handlers, folded into the feature) or
describe internals (stable ref names, AdminDashRemovedError), trim
implementation narrative, and order each category by user impact.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ESN8DhETqtSLLtGDUeGGwV

* Tidy the pending news fragments for the next 0.11 alpha

Drop fragments that fix behavior new in 0.11.0a1 (awaitable handler
returns and hints, @rx.event stacking, the storage factory check, the
alembic env.py and page-evaluation regressions, the refs import, the
same-origin proxy check, the auto_memoize warning) and fold what users
need from them into the matching 0.11.0a1 changelog entries. Remove the
reflex-base copies of fragments duplicated in reflex, the base half of the
upload error fix (kept in components-core), the dependency-floor and
docstring fragments, and merge the two DeclarativeBase detection
fragments. Recast the reflex.model import fix as a performance entry and
trim implementation detail from the rest.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ESN8DhETqtSLLtGDUeGGwV

* Materialize changelogs for [email protected], [email protected], [email protected] (continued-prerelease)

* Materialize the #7855 fragment under reflex-base 0.11.0a2

#7855 (Don't wait in Thread.join(timeout) when draining supervised output)
merged to main after 0.11.0a2 was cut. It ships in 0.11.0, so its entry
goes into the 0.11.0a2 section, which release-from-prerelease collapses
into the final 0.11.0 section, and the fragment is consumed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dxjadq3qkhKnqZR2b9WBFi

* Add the #7855 entry to the reflex-base 0.11.0a2 section

The previous commit consumed the fragment but left the changelog edit
unstaged; this adds the entry it was meant to carry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dxjadq3qkhKnqZR2b9WBFi

* Keep main's sibling floors instead of the train's alpha floors

The alpha materializations raised the root and reflex-components-core
floors to the train's alphas (reflex-components-core >= 0.11.0a1, ...).
Those tags live on r/pre-2026.11.11 and are not reachable from main, so
main's commits build the siblings as 0.10.2.devN / 1.1.2.devN, which
check-min-deps rejects. Keep main's .dev0 floors; release-from-prerelease
lifts each to the earliest published final once that sibling is tagged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Dxjadq3qkhKnqZR2b9WBFi

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude <[email protected]>
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 release-train Issues found during agentic /prerelease-testing fanout, not necessarily validated bugs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants