{"record":{"id":"8a54918a4ec0cfb2","repo":"langflow-ai/langflow","slug":"module-self-name-has-no-attribute-name","errorCode":null,"errorMessage":"module '{self.__name__}' has no attribute '{name}'","messagePattern":"module '(.+?)' has no attribute '(.+?)'","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"src/backend/base/langflow/__init__.py","lineNumber":141,"sourceCode":"\n    def _get_lfx_module(self):\n        \"\"\"Lazily import and cache the lfx module.\"\"\"\n        if self._lfx_module is None:\n            try:\n                self._lfx_module = importlib.import_module(self._lfx_module_name)\n            except ImportError as e:\n                msg = f\"Cannot import {self._lfx_module_name} for backwards compatibility with {self.__name__}\"\n                raise ImportError(msg) from e\n        return self._lfx_module\n\n    def __getattr__(self, name: str) -> Any:\n        \"\"\"Forward attribute access to the lfx module with caching.\"\"\"\n        lfx_module = self._get_lfx_module()\n        try:\n            attr = getattr(lfx_module, name)\n        except AttributeError as e:\n            msg = f\"module '{self.__name__}' has no attribute '{name}'\"\n            raise AttributeError(msg) from e\n        else:\n            # Cache the attribute in our __dict__ for faster subsequent access\n            setattr(self, name, attr)\n            return attr\n\n    def __dir__(self):\n        \"\"\"Return directory of the lfx module.\"\"\"\n        try:\n            lfx_module = self._get_lfx_module()\n            return dir(lfx_module)\n        except ImportError:\n            return []\n\n\ndef _setup_compatibility_modules():\n    \"\"\"Set up comprehensive compatibility modules for langflow.base imports.\"\"\"\n    # First, set up the base attribute on this module (langflow)\n    current_module = sys.modules[__name__]","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/__init__.py#L123-L159","documentation":"The lazy compat shim in langflow/__init__.py raises a plain AttributeError ('module ... has no attribute ...') when the forwarded attribute does not exist on the underlying lfx module. This mirrors normal Python semantics so hasattr() and try/except AttributeError keep working through the shim. It almost always means the symbol was renamed or moved during the langflow->lfx migration, not that the shim is broken.","triggerScenarios":"Accessing langflow.SomeSymbol where SomeSymbol exists neither in the legacy package's __dict__ nor on the lfx module the shim forwards to; using a symbol that was renamed/removed in the current lfx version.","commonSituations":"Upgrading across the langflow->lfx code move where a class or function was renamed (e.g. component base classes); stale custom code referencing pre-migration names; typo'd attribute that only fails at runtime due to lazy forwarding.","solutions":["Check what the lfx module actually exports: 'uv run python -c \"import lfx; print([n for n in dir(lfx) if 'Chat' in n])\"' and use the current name.","Search the repo for the new location: the symbol likely moved to lfx (grep for 'class <Symbol>' under src/lfx or src/backend).","If you maintain the shim mapping, add the missing re-export explicitly rather than relying on forwarding.","Pin to the langflow version whose API your code was written against until you migrate names."],"exampleFix":"# before\nfrom langflow import ChatInput  # AttributeError: module 'langflow' has no attribute 'ChatInput'\n# after: use the current lfx name\nfrom lfx.chat import ChatInput","handlingStrategy":"type-guard","validationCode":"import langflow\nname = \"ChatInput\"\nhas_it = hasattr(langflow, name)  # goes through the shim's __getattr__ safely","typeGuard":"def has_langflow_symbol(mod, name: str) -> bool:\n    \"\"\"True if the lazy compat shim can resolve the symbol.\"\"\"\n    return hasattr(mod, name)","tryCatchPattern":"try:\n    Symbol = langflow.ChatInput\nexcept AttributeError as e:\n    raise NotImplementedError(\n        f\"{e}: symbol was renamed/moved in the lfx migration — import from lfx directly\"\n    ) from e","preventionTips":["Prefer importing new code from lfx directly; treat langflow.* forwarding as legacy.","Pin versions while migrating custom components across the langflow->lfx split.","Use hasattr() before optional attribute access through the shim."],"tags":["import","attributeerror","lfx","backwards-compat"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}