Skip to content

Backend var Fields still fail late, with a generic error, or silently outside the LiteralVar path #7732

Closed

Description

@FarhanAliRaza

Status: #7651 fixes every row below and adds the missing rx.get_upload_url(F) test (at 224db98cc). It closes this issue when it merges.

Follow-up to #7459 and #7651.

#7651 makes the LiteralVar paths raise BackendVarFormatError for a Field with no frontend Var (rx.Var.create([F]), rx.toast(F), rx.image(src=F), rx.cond(F, ...), rx.foreach(F, ...), ...). The cases below do not go through LiteralVar, so they still fail with a generic error, fail late, or do not fail at all. I checked each one at #7651 head 4e71e5e08.

import reflex as rx


class S(rx.State):
    _secret: str = "x"
    _size: int = 16
    shown: str = "ok"


F = S._secret
Code Result now Expected
rx.box("x", id=F).render() TypeError: expected string or bytes-like object, got 'Field' BackendVarFormatError
app.add_page(index, title=F) ChildrenTypeError: Component Title received child Field(default='x', ...) at compile time. The traceback has no frame from the app file. BackendVarFormatError from add_page
rx.upload_files(upload_id="u", on_upload_progress=F) Returns a FileUpload. When it is bound to a handler: ValueError: Field(default='x', ...) is not a valid event handler. BackendVarFormatError from upload_files
str(S._size) + "px", "%s" % S._size, f"{S._size!s}" No error. The page gets the text Field(default=16, is_var=True, annotated_type=<class 'int'>)px. An error, or a documented limit
rx.Var.create([S.get_fields()["shown"]]), f"{S.get_fields()['shown']}" BackendVarFormatError: 'S.shown' has no frontend var, so it cannot be used in the UI. This is false: S.shown has a frontend Var. A message that says to use S.shown

Also from #7459: rx.get_upload_url(F) raises BackendVarFormatError as intended, but no test covers it.

The first three rows are the most useful to fix. In each one, the error does not name the field, so the user must search the code for the Field(...) text.

Activity

  1. linear-code commented on Nov 4, 2026

    @linear-code
  2. added
    error message
    on Nov 4, 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

    error message

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions