{"record":{"id":"5d23107652d99c90","repo":"langchain-ai/deepagents","slug":"class-class-name-not-found-in-module-module-5d2310","errorCode":null,"errorMessage":"Class '{class_name}' not found in module '{module_path}'","messagePattern":"Class '(.+?)' not found in module '(.+?)'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/integrations/sandbox_registry.py","lineNumber":107,"sourceCode":"    Returns:\n        The imported class object.\n\n    Raises:\n        ValueError: If `class_path` is malformed.\n        ImportError: If the module cannot be imported or lacks the class.\n    \"\"\"\n    if \":\" not in class_path:\n        msg = (\n            f\"Invalid class_path '{class_path}': must be in \"\n            \"module.path:ClassName format\"\n        )\n        raise ValueError(msg)\n    module_path, class_name = class_path.rsplit(\":\", 1)\n    module = importlib.import_module(module_path)\n    cls = getattr(module, class_name, None)\n    if cls is None or not isinstance(cls, type):\n        msg = f\"Class '{class_name}' not found in module '{module_path}'\"\n        raise ImportError(msg)\n    return cls\n\n\ndef _provider_metadata(provider: SandboxProvider, name: str) -> SandboxProviderMetadata:\n    \"\"\"Extract metadata from a provider instance or class.\n\n    Providers may expose a `metadata` attribute/property; otherwise a minimal\n    default is synthesized.\n\n    Args:\n        provider: Provider instance.\n        name: Provider name to use when synthesizing defaults.\n\n    Returns:\n        The provider's metadata.\n    \"\"\"\n    meta = getattr(provider, \"metadata\", None)\n    if isinstance(meta, SandboxProviderMetadata):","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/integrations/sandbox_registry.py#L89-L125","documentation":"`_load_class` imports the module portion of a class_path and then looks up the class attribute. If the attribute is missing or is not a type (e.g. it's a function or instance), an ImportError is raised naming the class and module, indicating the resolved entry point doesn't point at a class.","triggerScenarios":"`create_provider('myprov')` where the config's class_path names a class that doesn't exist in the module (`mypkg.providers:MyProvier` typo), or where the symbol is not a class (a factory function, constant, or lazily-imported name).","commonSituations":"Renaming or deleting a provider class without updating config, typos in the class name, pointing at a `create_provider()` factory function instead of the class itself, circular imports leaving the attribute unset.","solutions":["Verify the class name exists in the module: `python -c \"import mypkg.providers; print(mypkg.providers.MyProvider)\"`.","Correct the class name spelling in the `class_path` config value.","If the entry is a factory function, export a class or wrap it so the class_path points to a `type`."],"exampleFix":"# before\nclass_path = \"mypkg.providers:SandbxProvider\"  # typo\n# after\nclass_path = \"mypkg.providers:SandboxProvider\"","handlingStrategy":"validation","validationCode":"import importlib\n\ndef class_path_resolves(class_path: str) -> bool:\n    module_path, cls_name = class_path.rsplit(':', 1)\n    mod = importlib.import_module(module_path)\n    obj = getattr(mod, cls_name, None)\n    return isinstance(obj, type)","typeGuard":"def is_provider_class(obj: object) -> bool:\n    return isinstance(obj, type)","tryCatchPattern":"try:\n    provider = registry.create_provider(name)\nexcept ImportError as exc:\n    raise ConfigError(f'class_path points to a missing/non-class symbol: {exc}') from exc","preventionTips":["Smoke-test class_path resolution in CI before shipping config","Update class_path whenever the provider class is renamed or moved","Point class_path at the class itself, not a factory function"],"tags":["python","config","dynamic-import","import"],"backgroundTag":"class-not-found","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}