{"record":{"id":"da867a1dca331ea7","repo":"agentscope-ai/agentscope","slug":"module-agentscope-app-storage-has-no-attribute","errorCode":null,"errorMessage":"module 'agentscope.app.storage' has no attribute {name!r}","messagePattern":"module 'agentscope\\.app\\.storage' has no attribute (.+?)","errorType":"error_code","errorClass":"AttributeError","httpStatus":null,"severity":"error","filePath":"src/agentscope/app/storage/__init__.py","lineNumber":63,"sourceCode":"    # ``_sql`` package does at load time (its declarative-tables module\n    # cannot defer it).\n    from ._sql import AsyncSQLAlchemyStorage  # noqa: F401\n\n\ndef __getattr__(name: str) -> object:\n    \"\"\"Lazily load the optional SQL backend on first attribute access.\n\n    Keeps ``import agentscope.app.storage`` cheap — ``StorageBase``,\n    ``RedisStorage`` and the record models never need SQLAlchemy — while\n    still exposing ``AsyncSQLAlchemyStorage`` from this package for\n    callers that do ``from agentscope.app.storage import\n    AsyncSQLAlchemyStorage``. SQLAlchemy is imported only at that point.\n    \"\"\"\n    if name == \"AsyncSQLAlchemyStorage\":\n        from ._sql import AsyncSQLAlchemyStorage as _AsyncSQLAlchemyStorage\n\n        return _AsyncSQLAlchemyStorage\n    raise AttributeError(\n        f\"module 'agentscope.app.storage' has no attribute {name!r}\",\n    )\n\n\n__all__ = [\n    \"StorageBase\",\n    \"RedisStorage\",\n    \"AsyncSQLAlchemyStorage\",\n    # The ORM models\n    \"InviteConfig\",\n    \"AgentData\",\n    \"AgentRecord\",\n    \"ChannelBinding\",\n    \"ChannelRecord\",\n    \"ChunkerConfig\",\n    \"RoutingConfig\",\n    \"SessionScope\",\n    \"SessionSettings\",","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/app/storage/__init__.py#L45-L81","documentation":"The agentscope.app.storage package exposes StorageBase and lazy-loads some backends via module-level __getattr__. Requesting any attribute other than the explicitly supported names (e.g. AsyncSQLAlchemyStorage) raises AttributeError, because the package does not eagerly import all storage classes.","triggerScenarios":"Calling agentscope.app.storage.SomeBackend where SomeBackend is not StorageBase or AsyncSQLAlchemyStorage, e.g. `from agentscope.app.storage import MongoDBStorage` or `agentscope.app.storage.SQLAlchemyStorage` (the sync name).","commonSituations":"Guessing backend class names that don't exist, using the sync 'SQLAlchemyStorage' name instead of 'AsyncSQLAlchemyStorage', or referencing a backend that lives in a submodule (agentscope.app.storage._sql) directly after a version refactor moved classes behind lazy imports.","solutions":["Check agentscope.app.storage.__all__ / dir() to see which names the package actually exports","Use the supported name: from agentscope.app.storage import AsyncSQLAlchemyStorage","Import from the concrete submodule if you need an internal class: from agentscope.app.storage._sql import AsyncSQLAlchemyStorage","Verify class name spelling and that your agentscope version includes that backend"],"exampleFix":"// before\nfrom agentscope.app.storage import SQLAlchemyStorage  # AttributeError\n\n// after\nfrom agentscope.app.storage import AsyncSQLAlchemyStorage","handlingStrategy":"type-guard","validationCode":"import agentscope.app.storage as storage_pkg\n\nname = \"AsyncSQLAlchemyStorage\"\nif not hasattr(storage_pkg, name):\n    raise SystemExit(f\"backend {name} unavailable; see {storage_pkg.__all__}\")","typeGuard":"from agentscope.app.storage import StorageBase\n\ndef is_storage_backend(obj) -> TypeGuard[type[StorageBase]]:\n    return isinstance(obj, type) and issubclass(obj, StorageBase)","tryCatchPattern":null,"preventionTips":["Check __all__ or dir(agentscope.app.storage) before importing backend names","Pin the agentscope version and review changelogs when storage classes move","Import concrete classes from their defining submodule when you need internals"],"tags":["python","import","attributeerror","lazy-import","storage"],"backgroundTag":"module-has-no-attribute","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}