{"record":{"id":"af83529a9b93ef2e","repo":"headroomlabs-ai/headroom","slug":"module-name-r-has-no-attribute-name-r-af8352","errorCode":null,"errorMessage":"module {__name__!r} has no attribute {name!r}","messagePattern":"module (.+?) has no attribute (.+?)","errorType":"exception","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"headroom/providers/__init__.py","lineNumber":118,"sourceCode":"        \"create_anyscale_provider\",\n    ),\n    \"create_vllm_provider\": (\"headroom.providers.openai_compatible\", \"create_vllm_provider\"),\n    \"create_lmstudio_provider\": (\n        \"headroom.providers.openai_compatible\",\n        \"create_lmstudio_provider\",\n    ),\n    \"create_litellm_provider\": (\"headroom.providers.litellm\", \"create_litellm_provider\"),\n}\n\n\ndef __getattr__(name: str) -> object:\n    if name == \"__path__\":\n        raise AttributeError(name)\n\n    try:\n        module_name, attr_name = _LAZY_EXPORTS[name]\n    except KeyError as exc:\n        raise AttributeError(f\"module {__name__!r} has no attribute {name!r}\") from exc\n\n    module = import_module(module_name)\n    value = getattr(module, attr_name)\n    globals()[name] = value\n    return value\n\n\ndef __dir__() -> list[str]:\n    return sorted(set(globals()) | set(__all__))\n","sourceCodeStart":100,"sourceCodeEnd":128,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/providers/__init__.py#L100-L128","documentation":"Raised by the headroom.providers package's module-level __getattr__ when code accesses an attribute that is not in the _LAZY_EXPORTS lazy-import table. The package defers importing heavy provider backends, so every public name must be declared in _LAZY_EXPORTS; anything else (a typo, a renamed symbol, or a private name that was never exported) falls through to this AttributeError, chained from the KeyError on the lookup dict.","triggerScenarios":"from headroom.providers import SomeName where SomeName is misspelled or was renamed between versions; getattr(headroom.providers, name) with a dynamically built name that is not in _LAZY_EXPORTS; accessing a symbol that exists in a submodule (e.g. headroom.providers.litellm) directly on the package without an export entry.","commonSituations":"Upgrading headroom after a provider symbol was renamed or removed; IDE autocompleting a symbol from a submodule onto the package root; copy-pasted import paths from older docs or examples.","solutions":["Check the spelling against _LAZY_EXPORTS / __all__ in headroom/providers/__init__.py and import the exact exported name","Import from the concrete submodule instead: from headroom.providers.litellm import create_litellm_provider","If the symbol was renamed in a release, migrate to the new name (see CHANGELOG.md)"],"exampleFix":"// before\nfrom headroom.providers import create_litellm  # typo -> AttributeError\n\n// after\nfrom headroom.providers import create_litellm_provider\n# or directly from the module:\nfrom headroom.providers.litellm import create_litellm_provider","handlingStrategy":"validation","validationCode":"import headroom.providers as hp\n\nname = \"create_litellm_provider\"\nif name not in dir(hp):  # __dir__ unions globals() with __all__\n    raise ImportError(f\"{name} is not exported by headroom.providers\")\nobj = getattr(hp, name)","typeGuard":"def is_lazy_export(name: str) -> bool:\n    import headroom.providers as hp\n    return name in hp.__all__","tryCatchPattern":"try:\n    from headroom.providers import create_litellm_provider\nexcept AttributeError as e:\n    # fall back to the concrete submodule, which always works\n    from headroom.providers.litellm import create_litellm_provider","preventionTips":["Import provider symbols from their concrete submodules for stability","Pin headroom versions and re-check exports after upgrades","Validate dynamically built import names against __all__ before getattr"],"tags":["imports","lazy-loading","attributeerror"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}