Skip to content

Error message when passing Plugin class in rx.Config is terrible #6440

@masenf

Description

@masenf

Describe the bug

import reflex as rx

config = rx.Config(
    app_name="repro_sitemap",
    plugins=[
        rx.plugins.SitemapPlugin,
        rx.plugins.TailwindV4Plugin(),
    ]
)

To Reproduce
Any plugin in the list that is not an instance will trigger the following exception:

Traceback (most recent call last):
  File "/Users/masenf/code/reflex-dev/repro-sitemap/.venv/lib/python3.14/site-packages/reflex/utils/prerequisites.py", line 351, in 
compile_or_validate_app
    get_compiled_app(
    ~~~~~~~~~~~~~~~~^
        check_if_schema_up_to_date=check_if_schema_up_to_date,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        prerender_routes=prerender_routes,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/masenf/code/reflex-dev/repro-sitemap/.venv/lib/python3.14/site-packages/reflex/utils/prerequisites.py", line 270, in get_compiled_app
    app._compile(prerender_routes=prerender_routes, dry_run=dry_run, use_rich=use_rich)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/masenf/code/reflex-dev/repro-sitemap/.venv/lib/python3.14/site-packages/reflex/app.py", line 1478, in _compile
    _submit_work(
    ~~~~~~~~~~~~^
        compiler.compile_root_stylesheet, self.stylesheets, self.reset_style
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/masenf/code/reflex-dev/repro-sitemap/.venv/lib/python3.14/site-packages/reflex/app.py", line 1466, in _submit_work
    f = executor.submit(fn, *args, **kwargs)
  File "/Users/masenf/code/reflex-dev/repro-sitemap/.venv/lib/python3.14/site-packages/reflex_base/environment.py", line 615, in submit
    future_job.set_result(fn(*args, **kwargs))
                          ~~^^^^^^^^^^^^^^^^^
  File "/Users/masenf/code/reflex-dev/repro-sitemap/.venv/lib/python3.14/site-packages/reflex/compiler/compiler.py", line 191, in 
compile_root_stylesheet
    code = _compile_root_stylesheet(stylesheets, reset_style)
  File "/Users/masenf/code/reflex-dev/repro-sitemap/.venv/lib/python3.14/site-packages/reflex/compiler/compiler.py", line 260, in 
_compile_root_stylesheet
    for sheet in plugin.get_stylesheet_paths()
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
TypeError: Plugin.get_stylesheet_paths() missing 1 required positional argument: 'self'

Expected behavior
we should probably do one of two things in the framework though:

  1. error if the user does not pass an instance of Plugin
  2. try to create an instance from a Plugin class by passing no arguments

Number 1 is the most philosophically pure: use the API correctly or it doesn't work at all. Number 2 would be more along the lines of the old reflex philosophy.

Specifics (please complete the following information):

  • Python Version: 3.10+
  • Reflex Version: 0.9.1
  • OS: any

Additional context
Any fix should add tests and make sure to implement the validation for this plugin checking in a reasonable place: it shouldn't happen every time a plugin is invoked.

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