Skip to content

select_files fails when passed a var[str] #5490

@bertbarabas

Description

@bertbarabas

Describe the bug
The following fails when
id = required_file.file_name_id
but works if
id=f"{required_file.file_name_id}"

        rx.foreach(
            rx.selected_files(id),
            file_to_upload,
        ),

exception is:

  File ".venv\Lib\site-packages\reflex\components\core\upload.py", line 90, in selected_files
    id_var = LiteralStringVar.create(id_)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv\Lib\site-packages\reflex\vars\sequence.py", line 1173, in create
    if REFLEX_VAR_OPENING_TAG in value:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv\Lib\site-packages\reflex\vars\base.py", line 1420, in __contains__
    raise VarTypeError(msg)
reflex.utils.exceptions.VarTypeError: 'in' operator not supported for Var types, use Var.contains() instead.
Happened while evaluating page 'console'

Expected behavior
No exception

Specifics (please complete the following information):

  • Python Version: 3.12.4
  • Reflex Version: 0.7.4
  • OS: Window 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions