{"record":{"id":"9be67e9673667b5e","repo":"langflow-ai/langflow","slug":"module-name-r-has-no-attribute-attr-name-r","errorCode":null,"errorMessage":"module {__name__!r} has no attribute {attr_name!r}","messagePattern":"module (.+?) has no attribute (.+?)","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"scripts/migrate/port_bundle.py","lineNumber":286,"sourceCode":"\nfrom __future__ import annotations\n\nfrom typing import TYPE_CHECKING, Any\n\nfrom lfx.components._importing import import_mod\n\nif TYPE_CHECKING:\n{type_checking_imports}\n\n_dynamic_imports = {dynamic_imports_dict}\n\n__all__ = {all_list}\n\n\ndef __getattr__(attr_name: str) -> Any:\n    if attr_name not in _dynamic_imports:\n        msg = f\"module {{__name__!r}} has no attribute {{attr_name!r}}\"\n        raise AttributeError(msg)\n    try:\n        result = import_mod(attr_name, _dynamic_imports[attr_name], __spec__.parent)\n    except (ModuleNotFoundError, ImportError, AttributeError) as e:\n        msg = f\"Could not import {{attr_name!r}} from {{__name__!r}}: {{e}}\"\n        raise AttributeError(msg) from e\n    globals()[attr_name] = result\n    return result\n\n\ndef __dir__() -> list[str]:\n    return list(__all__)\n'''\n\n\nBASE_INIT_TEMPLATE = '''\\\n\"\"\"Shared base infrastructure for the {bundle} bundle.\n\nHouses the mixin(s) every component in this bundle inherits from --","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/scripts/migrate/port_bundle.py#L268-L304","documentation":"This message lives inside a Python module template that port_bundle.py writes into the generated bundle's lazy __init__.py (PEP 562 module-level __getattr__). The generated package maps each public attribute name to a submodule via a _dynamic_imports dict; accessing any attribute NOT in that dict raises the standard AttributeError 'module <name> has no attribute <attr>' with this exact f-string. It is ordinary Python lazy-import behavior, not a migration-script failure — you hit it at runtime when using the generated lfx_<bundle> package.","triggerScenarios":"After a bundle is ported, calling e.g. `from lfx_helpers import Something` or `lfx_helpers.Something` where 'Something' was not registered in the generated _dynamic_imports (misspelled class, private helper, or a name that never existed in the provider).","commonSituations":"Consumers guessing attribute names instead of importing from submodules; a class renamed during the port; IDE autocomplete suggesting stale names from before the split.","solutions":["Check the generated __init__.py's __all__ / _dynamic_imports (or call dir() on the module) to see the names the bundle actually exports.","Import from the concrete submodule instead: `from lfx_helpers.<module> import Something`.","If a public class is genuinely missing from _dynamic_imports, that is a port bug — re-run/patch the generated __init__ so the class is listed."],"exampleFix":"# before\nimport lfx_helpers\nlfx_helpers.ChatImput  # AttributeError: module 'lfx_helpers' has no attribute 'ChatImput'\n\n# after\nfrom lfx_helpers.chat_input import ChatInput","handlingStrategy":"type-guard","validationCode":"import lfx_helpers\n\nname = \"ChatInput\"\nif name not in getattr(lfx_helpers, \"__all__\", ()):\n    raise AttributeError(f\"{name!r} is not exported by lfx_helpers; available: {lfx_helpers.__all__}\")\nobj = getattr(lfx_helpers, name)","typeGuard":"def exports(module: object, attr: str) -> bool:\n    \"\"\"True if a lazy PEP 562 module advertises attr in __all__ / _dynamic_imports.\"\"\"\n    dyn = getattr(module, \"_dynamic_imports\", None)\n    if isinstance(dyn, dict):\n        return attr in dyn\n    return attr in getattr(module, \"__all__\", ())","tryCatchPattern":"try:\n    ChatInput = lfx_helpers.ChatInput\nexcept AttributeError as exc:\n    # misspelled or unregistered name — fall back to the concrete submodule\n    from lfx_helpers.chat_input import ChatInput","preventionTips":["Programmatic access should go through __all__/dir() rather than blind attribute access on lazy packages.","After a port, grep consumers for the old attribute names to catch renames early.","If a genuinely public class is missing from _dynamic_imports, treat it as a port bug and fix the generated __init__."],"tags":["python","lazy-import","attribute-error","migration"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}