{"record":{"id":"7f2723ffb4d804ba","repo":"reflex-dev/reflex","slug":"failed-to-get-plugin-class-plugin-name-r-from-mo","errorCode":null,"errorMessage":"Failed to get plugin class {plugin_name!r} from module {import_path!r} for {field_name}: {e}","messagePattern":"Failed to get plugin class (.+?) from module (.+?) for (.+?): (.+?)","errorType":"exception","errorClass":"EnvironmentVarValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-base/src/reflex_base/environment.py","lineNumber":206,"sourceCode":"        EnvironmentVarValueError: If the value is invalid.\n    \"\"\"\n    if \".\" not in value:\n        msg = f\"Invalid plugin value: {value!r} for {field_name}. Plugin name must be in the format 'package.module.PluginName'.\"\n        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\").","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/environment.py#L188-L224","documentation":"After importing the module, getattr(module, plugin_name) failed or raised; the exception is chained into EnvironmentVarValueError. Most commonly the attribute simply doesn't exist on the module (getattr raises AttributeError, caught by the broad `except Exception`).","triggerScenarios":"The class name portion of the dotted path is misspelled, the class is private/renamed in a newer plugin version, or module-level code in a descriptor raises during attribute access.","commonSituations":"Plugin upgrade renamed the class, wrong class name in env var, or the module exposing a factory function instead of a class.","solutions":["Check the class exists: python -c \"from my_plugins import module; print(module.MyPlugin)\"","Fix the class name spelling / use the new name after a plugin upgrade","If the plugin exposes a function, wrap it in a class that subclasses Plugin"],"exampleFix":"# before\nREFLEX_PLUGIN=my_plugins.module.MyPlugn  # typo\n# after\nREFLEX_PLUGIN=my_plugins.module.MyPlugin\n","handlingStrategy":"validation","validationCode":"import importlib\nmod_path, cls_name = value.rsplit(\".\", 1)\nassert hasattr(importlib.import_module(mod_path), cls_name), f\"{cls_name} not found in {mod_path}\"","typeGuard":"def plugin_class_exists(value: str) -> bool:\n    mod_path, cls_name = value.rsplit(\".\", 1)\n    try:\n        return hasattr(importlib.import_module(mod_path), cls_name)\n    except Exception:\n        return False","tryCatchPattern":"except EnvironmentVarValueError as e:\n    if \"Failed to get plugin class\" in str(e):\n        # fix path or disable plugin\n        ...","preventionTips":["Pin plugin versions so class names don't shift under you","Add a unit test importing every configured plugin path"],"tags":["environment","plugin","import","attribute-error"],"backgroundTag":"plugin-import-failed","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}