Skip to content

Backend var Fields are accepted by several APIs and fail later at render/compile time #7459

Closed

Description

@masenf

Follow-up to #7456.

Class access to a field with no frontend Var returns the raw Field descriptor. That covers State._secret, a field declared with rx.field(..., is_var=False), and any field of a mixin state. Users pass it by mistake wherever a state var fits. After #7456, every error message on these paths reports the field's repr. But the APIs below accept the Field without complaint at the call site, so the failure only shows up later, when the page renders or compiles, with a generic error and a traceback nowhere near the user's line.

With F = State._secret:

Call What happens
rx.toast(F), rx.console_log(F) TypeError: Unsupported type ... for LiteralVar when the event chain is rendered
rx.image(src=F), rx.data_table(data=F) same TypeError when the component is rendered
rx.Var.create([F]), rx.Var.create({"a": F}) same TypeError when the Var is stringified
rx.upload_files(upload_id="u", on_upload_progress=F) returns a FileUpload holding the Field; it fails only when bound to a handler
app.add_page(..., title=F) (presumably description and image too) stored as-is; compiling it raises ChildrenTypeError from Title.create

Proposal: reject a Field where it is passed in (event actions, untyped/Any props, nested values in LiteralVar.create, page metadata) with a clear message, ideally BackendVarFormatError's wording so users get the same explanation.

Also worth a test: rx.get_upload_url(F) (reflex_components_core/core/upload.py) and the reflex/experimental/hooks.py helpers now raise BackendVarFormatError where they used to silently put Field(...) into a URL or into JS. That's the intended behaviour, but no test covers it.

Activity

  1. added theissue type on Oct 6, 2026
  2. linear-code commented on Oct 6, 2026

    @linear-code
  3. changed the title [-]Backend var Fields are accepted by many APIs and fail later, or get a generic error[/-] [+]Backend var Fields are accepted by several APIs and fail later at render/compile time[/+] on Oct 6, 2026
  4. masenf commented on Oct 8, 2026

    @masenf
    CollaboratorAuthor

    Two more cases from the 0.10.0a3 pre-release re-check (finding N-006). #7475 fixed the BackendVarFormatError wording, but these paths still never reach it:

    • Silent string embedding: str(S._size) + "px", "%s" % S._size and f"{S._size!s}" silently embed Field(default=16, ...) in the rendered value. The 0.10 upgrade guide now documents this, but nothing raises.
    • Cryptic error: rx.box(id=S._label) fails with TypeError: expected string or bytes-like object, got 'Field' instead of BackendVarFormatError.

    Script: prerelease_testing/2026-10-07/reverify_core/scripts/derive_e_format.py.``


    Generated by Claude Code

  5. added
    release-train
    on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    release-train

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions