{"record":{"id":"751f3a6594239fa5","repo":"Textualize/textual","slug":"no-child-found-with-id-id-r","errorCode":null,"errorMessage":"No child found with id={id!r}","messagePattern":"No child found with id=(.+?)","errorType":"exception","errorClass":"NoMatches","httpStatus":null,"severity":"error","filePath":"src/textual/widget.py","lineNumber":1109,"sourceCode":"    def get_child_by_id(\n        self, id: str, expect_type: type[ExpectType] | None = None\n    ) -> ExpectType | Widget:\n        \"\"\"Return the first child (immediate descendent) of this node with the given ID.\n\n        Args:\n            id: The ID of the child.\n            expect_type: Require the object be of the supplied type, or None for any type.\n\n        Returns:\n            The first child of this node with the ID.\n\n        Raises:\n            NoMatches: if no children could be found for this ID\n            WrongType: if the wrong type was found.\n        \"\"\"\n        child = self._get_dom_base()._nodes._get_by_id(id)\n        if child is None:\n            raise NoMatches(f\"No child found with id={id!r}\")\n        if expect_type is None:\n            return child\n        if not isinstance(child, expect_type):\n            raise WrongType(\n                f\"Child with id={id!r} is the wrong type; expected type {expect_type.__name__!r}, found {child}\"\n            )\n        return child\n\n    if TYPE_CHECKING:\n\n        @overload\n        def get_widget_by_id(self, id: str) -> Widget: ...\n\n        @overload\n        def get_widget_by_id(\n            self, id: str, expect_type: type[ExpectType]\n        ) -> ExpectType: ...\n","sourceCodeStart":1091,"sourceCodeEnd":1127,"githubUrl":"https://github.com/Textualize/textual/blob/06dbeef4bb70fb718236aa418ed658ef4667a126/src/textual/widget.py#L1091-L1127","documentation":"get_child_by_id searches only immediate children by their id attribute; NoMatches is raised when no direct child carries that id (grandchildren are not searched).","triggerScenarios":"Calling get_child_by_id(\"x\") where the id exists deeper in the tree, on a different parent, or was never set/has a typo.","commonSituations":"Assuming deep search like query(); ids set in compose() of a grandchild; leading '#' accidentally included in the id string.","solutions":["Use query_one(\"#id\") or get_widget_by_id for deep descendants","Verify the id is set on an immediate child in compose()","Pass the id without the '#' prefix"],"exampleFix":"# before\nchild = self.get_child_by_id(\"inner\")\n# after\nchild = self.query_one(\"#inner\")","handlingStrategy":"validation","validationCode":"child = self._get_dom_base()._nodes._get_by_id(id)\nif child is None:\n    child = self.query_one(f\"#{id}\")  # fall back to deep search","typeGuard":null,"tryCatchPattern":"try:\n    w = parent.get_child_by_id(\"x\")\nexcept NoMatches:\n    w = parent.query_one(\"#x\")","preventionTips":["Remember get_child_by_id is immediate-children-only","Set ids in compose() and keep them stable"],"tags":["dom-tree","lookup","widget","textual"],"backgroundTag":"element-not-found","analyzedSha":"06dbeef4bb70fb718236aa418ed658ef4667a126","analyzedAt":"2026-08-27T02:36:57.214Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}