{"record":{"id":"7a0d9323facbaa34","repo":"sgl-project/sglang","slug":"did-not-declare-component-use","errorCode":null,"errorMessage":"{} did not declare component use: {}","messagePattern":"(.+?) did not declare component use: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/multimodal_gen/runtime/pipelines_core/stages/base.py","lineNumber":217,"sourceCode":"    def _declared_component_use(\n        self,\n        *,\n        component_name: str,\n        phase: str | None = None,\n        target_dtype: torch.dtype | None = None,\n    ) -> ComponentUse:\n        manager = self._component_residency_manager\n        stage_name = self._active_component_stage_name()\n        server_args = manager.server_args if manager is not None else self.server_args\n        for use in self.component_uses(server_args, stage_name):\n            if use.component_name != component_name:\n                continue\n            if phase is not None and use.phase != phase:\n                continue\n            if target_dtype is not None:\n                return replace(use, target_dtype=target_dtype)\n            return use\n        raise ValueError(\n            f\"{self.__class__.__name__} did not declare component use: \"\n            f\"{component_name}\"\n        )\n\n    @contextmanager\n    def use_declared_component(\n        self,\n        *,\n        component_name: str,\n        module=None,\n        phase: str | None = None,\n        target_dtype: torch.dtype | None = None,\n    ) -> Iterator[object | None]:\n        \"\"\"reference a component already declared in `component_uses`\"\"\"\n        use = self._declared_component_use(\n            component_name=component_name,\n            phase=phase,\n            target_dtype=target_dtype,","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/multimodal_gen/runtime/pipelines_core/stages/base.py#L199-L235","documentation":"Stages must declare component usage (e.g. transformer/text-encoder use sites) up front via declared component-use records; _declared_component_use looks up a declared use by component_name (+optional phase, target_dtype) and raises if none matches.","triggerScenarios":"Calling stage.use_declared_component('transformer') (or begin_declared_component_use / internal transform use-site helpers) when the stage class never declared that component, or declared it under a different phase.","commonSituations":"Subclassing a Stage and overriding declarations; renaming a component or phase constant between versions; calling the context manager with a typo in the component name.","solutions":["Declare the component use in the stage (add to its declared component-use list/property) with the same name and phase","Fix the component_name string/typo to match the declaration","Check phase and target_dtype arguments match a declared entry"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"uses = stage.declared_component_uses() if hasattr(stage, 'declared_component_uses') else []\nnames = {u.component_name for u in uses}\nassert 'transformer' in names","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare component uses in __init_declared_uses__-style hooks of every Stage subclass","Add a unit test asserting each use_declared_component call has a declaration"],"tags":["stage","component-declaration","pipeline"],"backgroundTag":"undeclared-resource-use","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}