{"record":{"id":"0d1f41e9bc111dee","repo":"mudler/LocalAI","slug":"could-not-find-base-class-base-class-name-in-d","errorCode":null,"errorMessage":"Could not find base class '{base_class_name}' in diffusers","messagePattern":"Could not find base class '(.+?)' in diffusers","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/python/diffusers/diffusers_dynamic_loader.py","lineNumber":180,"sourceCode":"    import diffusers\n\n    # Try to get the base class from diffusers\n    base_class = None\n    try:\n        base_class = getattr(diffusers, base_class_name)\n    except AttributeError:\n        # Try to find in submodules\n        for submodule in ['schedulers', 'models', 'pipelines']:\n            try:\n                module = importlib.import_module(f'diffusers.{submodule}')\n                if hasattr(module, base_class_name):\n                    base_class = getattr(module, base_class_name)\n                    break\n            except (ImportError, ModuleNotFoundError):\n                continue\n\n    if base_class is None:\n        raise ValueError(f\"Could not find base class '{base_class_name}' in diffusers\")\n\n    registry: Dict[str, Type] = {}\n\n    # Include base class if requested\n    if include_base:\n        registry[base_class_name] = base_class\n\n    # Scan diffusers module for subclasses\n    for attr_name in dir(diffusers):\n        try:\n            attr = getattr(diffusers, attr_name)\n            if (isinstance(attr, type) and\n                issubclass(attr, base_class) and\n                (include_base or attr is not base_class)):\n                registry[attr_name] = attr\n        except (ImportError, AttributeError, TypeError, RuntimeError, ModuleNotFoundError):\n            continue\n","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/python/diffusers/diffusers_dynamic_loader.py#L162-L198","documentation":"Raised by the diffusers dynamic loader when building the pipeline registry: the requested base class name cannot be found on the top-level diffusers module nor in the 'schedulers', 'models', 'pipelines' submodules. The loader then cannot enumerate subclasses to populate the registry.","triggerScenarios":"get_pipeline_registry (or a caller) requests a base class name that does not exist in the installed diffusers version — e.g. a renamed or removed class, or a typo in the base_class_name argument.","commonSituations":"diffusers version drift (class renamed upstream, e.g. scheduler refactorings), a backend image pinned to an older diffusers while the code expects a newer class, or custom pipeline loading paths passing an arbitrary string as base class.","solutions":["Print [c for c in dir(diffusers) if 'Pipeline' in c] against the installed diffusers to find the current class name.","Upgrade/downgrade diffusers to the version the backend code was written against (check the backend image's requirements pin).","Use the canonical base class 'DiffusionPipeline' unless a specific subclass registry is required.","Fix the typo/case of base_class_name at the call site."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import diffusers\nassert hasattr(diffusers, base_class_name) or any(\n    hasattr(importlib.import_module(f'diffusers.{m}'), base_class_name)\n    for m in ('schedulers', 'models', 'pipelines')\n), f\"base class {base_class_name} absent from diffusers {diffusers.__version__}\"","typeGuard":"def base_class_exists(name: str) -> bool:\n    import diffusers\n    if hasattr(diffusers, name):\n        return True\n    return any(\n        hasattr(importlib.import_module(f'diffusers.{m}'), name)\n        for m in ('schedulers', 'models', 'pipelines')\n    )","tryCatchPattern":"try:\n    registry = _discover_pipelines(base_class_name)\nexcept ValueError as e:\n    logger.error(\"%s (diffusers %s)\", e, diffusers.__version__)\n    registry = _discover_pipelines(\"DiffusionPipeline\")  # only if fallback acceptable","preventionTips":["Pin the diffusers version the backend was built against.","Prefer the canonical 'DiffusionPipeline' base for generic registries.","Smoke-test registry discovery at backend startup, not on first request."],"tags":["diffusers","pipeline-registry","version-mismatch","dependency"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}