{"record":{"id":"80c780c8868bdbaa","repo":"reflex-dev/reflex","slug":"invalid-plugin-class-plugin-name-r-for-field-n","errorCode":null,"errorMessage":"Invalid plugin class: {plugin_name!r} for {field_name}. Must be a subclass of Plugin.","messagePattern":"Invalid plugin class: (.+?) for (.+?)\\. Must be a subclass of Plugin\\.","errorType":"exception","errorClass":"EnvironmentVarValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-base/src/reflex_base/environment.py","lineNumber":210,"sourceCode":"        raise EnvironmentVarValueError(msg)\n\n    import_path, plugin_name = value.rsplit(\".\", 1)\n\n    try:\n        module = importlib.import_module(import_path)\n    except ImportError as e:\n        msg = f\"Failed to import module {import_path!r} for {field_name}: {e}\"\n        raise EnvironmentVarValueError(msg) from e\n\n    try:\n        plugin_class = getattr(module, plugin_name)\n    except Exception as e:\n        msg = f\"Failed to get plugin class {plugin_name!r} from module {import_path!r} for {field_name}: {e}\"\n        raise EnvironmentVarValueError(msg) from e\n\n    if not isinstance(plugin_class, type) or not issubclass(plugin_class, Plugin):\n        msg = f\"Invalid plugin class: {plugin_name!r} for {field_name}. Must be a subclass of Plugin.\"\n        raise EnvironmentVarValueError(msg)\n\n    return plugin_class\n\n\ndef interpret_plugin_env(value: str, field_name: str) -> Plugin:\n    \"\"\"Interpret a plugin environment variable value.\n\n    Resolves a fully qualified import path and returns an instance of the Plugin.\n    On failure (bad import path or instantiation error) an ``_InvalidPlugin``\n    recording the error is returned instead of raising, so callers can decide\n    whether a bad entry is fatal.\n\n    Args:\n        value: The environment variable value (e.g. \"reflex.plugins.sitemap.SitemapPlugin\").\n        field_name: The field name.\n\n    Returns:\n        An instance of the Plugin subclass, or an ``_InvalidPlugin`` on failure.","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/environment.py#L192-L228","documentation":"The imported attribute was resolved, but the final validation requires it to be a class (isinstance(x, type)) and a subclass of Plugin. Anything else — an instance, a function, or an unrelated class — raises EnvironmentVarValueError.","triggerScenarios":"Pointing the env var at a function or instantiated object (module.make_plugin()), or at a class that doesn't inherit from reflex Plugin.","commonSituations":"Plugin written against a different base class or an older API, or a factory function mistaken for the plugin class.","solutions":["Point the env var at the Plugin subclass itself, not an instance or factory","Make your class inherit from the correct Plugin base (reflex.plugins.Plugin / the base used in reflex_base.environment)","If using a factory, define a thin subclass that wires it up"],"exampleFix":"# before\ndef make_plugin(): return MyPluginImpl()  # env points at make_plugin\n# after\nclass MyPlugin(Plugin):\n    ...\n# env: my_plugins.module.MyPlugin\n","handlingStrategy":"type-guard","validationCode":"mod = importlib.import_module(mod_path)\ncls = getattr(mod, cls_name, None)\nassert isinstance(cls, type) and issubclass(cls, Plugin), \"must be a Plugin subclass\"","typeGuard":"def is_plugin_class(value: str) -> bool:\n    try:\n        mod_path, cls_name = value.rsplit(\".\", 1)\n        cls = getattr(importlib.import_module(mod_path), cls_name)\n        return isinstance(cls, type) and issubclass(cls, Plugin)\n    except Exception:\n        return False","tryCatchPattern":"null","preventionTips":["Point env vars at classes, never factories or instances","Subclass the Plugin base the framework checks against"],"tags":["environment","plugin","type-validation","subclass"],"backgroundTag":"plugin-import-failed","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}