{"record":{"id":"3803e1c2d74fc9d1","repo":"headroomlabs-ai/headroom","slug":"module-name-r-has-no-attribute-name-r-3803e1","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/proxy/__init__.py","lineNumber":27,"sourceCode":"\n    # Use with Claude Code\n    ANTHROPIC_BASE_URL=http://localhost:8787 claude\n\n    # Use with Cursor (if using Anthropic)\n    Set base URL in Cursor settings to http://localhost:8787\n\"\"\"\n\n__all__ = [\"create_app\", \"run_server\"]\n\n\ndef __getattr__(name: str) -> object:\n    if name in (\"create_app\", \"run_server\"):\n        from .server import create_app, run_server  # noqa: F811\n\n        globals()[\"create_app\"] = create_app\n        globals()[\"run_server\"] = run_server\n        return globals()[name]\n    raise AttributeError(f\"module {__name__!r} has no attribute {name!r}\")\n","sourceCodeStart":9,"sourceCodeEnd":28,"githubUrl":"https://github.com/headroomlabs-ai/headroom/blob/322425c43bffde1ed0b64fecf3cf5951565dd82b/headroom/proxy/__init__.py#L9-L28","documentation":"headroom.proxy is a lazily-imported package: only create_app and run_server are exposed via module-level __getattr__, which imports them from headroom.proxy.server on first access and caches the attribute. Any other attribute access raises a plain AttributeError with this message. This is a normal Python import-error path, so the fix is to import the real symbol from the submodule that defines it.","triggerScenarios":"Accessing anything other than headroom.proxy.create_app or headroom.proxy.run_server — e.g. `from headroom.proxy import AnthropicHandler`, `headroom.proxy.config`, or a typo like `headroom.proxy.createServer`.","commonSituations":"IDE autocompleting a symbol that exists in a submodule but not at package level; porting code that imported from an older non-lazy layout; hasattr() checks triggering the __getattr__ and returning False for symbols that live in submodules.","solutions":["Import the symbol from its defining submodule, e.g. `from headroom.proxy.server import create_app, run_server`.","If the symbol is a handler/helper, find its real module (headroom.proxy.handlers.*, headroom.proxy.helpers) and import from there.","Check spelling first — only create_app and run_server are re-exported at package level."],"exampleFix":"# before\nfrom headroom.proxy import create_server  # AttributeError\n\n# after\nfrom headroom.proxy import run_server  # or: from headroom.proxy.server import create_app","handlingStrategy":"type-guard","validationCode":"import headroom.proxy as hp\n\n# only these two are re-exported lazily\nassert set(hp.__all__) <= {\"create_app\", \"run_server\"}\nsymbol_ok = name in hp.__all__","typeGuard":"import headroom.proxy as hp\n\ndef is_proxy_export(name: str) -> bool:\n    return name in getattr(hp, \"__all__\", ())","tryCatchPattern":"try:\n    create_app = getattr(headroom.proxy, \"create_app\")\nexcept AttributeError as exc:\n    raise ImportError(\"import from headroom.proxy.server directly\") from exc","preventionTips":["Import from the defining submodule (headroom.proxy.server, headroom.proxy.handlers.*) rather than the package root.","Don't rely on hasattr on the package: lazy __getattr__ makes most names report absent.","Pin against headroom's __all__ in tests that assert the public surface."],"tags":["python","import","lazy-loading","api-surface"],"backgroundTag":null,"analyzedSha":"322425c43bffde1ed0b64fecf3cf5951565dd82b","analyzedAt":"2026-08-15T01:03:05.481Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}