{"record":{"id":"d262441664eeda78","repo":"sgl-project/sglang","slug":"pipeline-config-cls-must-inherit-from-pipelineconf","errorCode":null,"errorMessage":"pipeline_config_cls must inherit from PipelineConfig","messagePattern":"pipeline_config_cls must inherit from PipelineConfig","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/registry.py","lineNumber":391,"sourceCode":"            _MODEL_NAME_DETECTORS.append((model_id, detector))\n    return model_id\n\n\ndef register_pipeline(\n    pipeline_cls: Type[ComposedPipelineBase],\n    *,\n    sampling_param_cls: Any,\n    pipeline_config_cls: Type[PipelineConfig],\n    hf_model_paths: Optional[List[str]] = None,\n    model_detectors: Optional[List[Callable[[str], bool]]] = None,\n    overwrite: bool = False,\n) -> None:\n    \"\"\"Register an out-of-tree native diffusion pipeline and its configs.\"\"\"\n    _discover_and_register_pipelines()\n    if not issubclass(pipeline_cls, ComposedPipelineBase):\n        raise TypeError(\"pipeline_cls must inherit from ComposedPipelineBase\")\n    if not issubclass(pipeline_config_cls, PipelineConfig):\n        raise TypeError(\"pipeline_config_cls must inherit from PipelineConfig\")\n\n    pipeline_name = pipeline_cls.pipeline_name\n    existing_pipeline = _PIPELINE_REGISTRY.get(pipeline_name)\n    if existing_pipeline is not None and not overwrite:\n        raise ValueError(\n            f\"Pipeline '{pipeline_name}' is already registered; pass overwrite=True to replace it\"\n        )\n    for model_path in hf_model_paths or []:\n        if model_path in _MODEL_HF_PATH_TO_NAME and not overwrite:\n            raise ValueError(f\"Model path '{model_path}' is already registered\")\n        registered_pipeline = KNOWN_NON_DIFFUSERS_DIFFUSION_MODEL_PATTERNS.get(\n            model_path.lower()\n        )\n        if registered_pipeline is not None and not overwrite:\n            raise ValueError(\n                f\"Model path '{model_path}' is already registered for pipeline \"\n                f\"'{registered_pipeline}'\"\n            )","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/registry.py#L373-L409","documentation":"The second validation in register_pipeline requires pipeline_config_cls to be a subclass of PipelineConfig. Passing any other class (a dataclass, dict wrapper, or the pipeline class again) raises TypeError before any registry mutation happens.","triggerScenarios":"Calling register_pipeline(PipelineCls, ConfigCls) where ConfigCls is not a PipelineConfig subclass — e.g. a plain dataclass or the model class itself.","commonSituations":"Swapping the two positional arguments; writing a custom config as a @dataclass instead of subclassing PipelineConfig; copying a diffusers registration snippet into sglang.","solutions":["Subclass PipelineConfig for your config class and pass it as the second argument","Double-check argument order: (pipeline_cls, pipeline_config_cls)","Re-run registration after fixing; the checks run before the registry is modified, so state stays clean"],"exampleFix":"# before\n@dataclass\nclass MyConfig: ...\nregister_pipeline(MyPipeline, MyConfig)\n# after\nfrom sglang.multimodal_gen.pipelines import PipelineConfig\nclass MyConfig(PipelineConfig): ...\nregister_pipeline(MyPipeline, MyConfig)","handlingStrategy":"type-guard","validationCode":"from sglang.multimodal_gen.pipelines import PipelineConfig\nassert issubclass(MyConfig, PipelineConfig), \"config must subclass PipelineConfig\"","typeGuard":"def is_pipeline_config(cls) -> bool:\n    from sglang.multimodal_gen.pipelines import PipelineConfig\n    return isinstance(cls, type) and issubclass(cls, PipelineConfig)","tryCatchPattern":"try:\n    register_pipeline(pipeline_cls=MyPipeline, pipeline_config_cls=MyConfig)\nexcept TypeError as e:\n    if \"PipelineConfig\" in str(e):\n        raise RuntimeError(f\"{MyConfig} must inherit PipelineConfig\") from e\n    raise","preventionTips":["Use keyword args to avoid positional swaps","Subclass PipelineConfig rather than writing a bare dataclass","Test registration in CI so config-class mistakes surface early"],"tags":["type-error","registry","pipeline-config","validation","subclass"],"backgroundTag":"invalid-registry-entry","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}