{"record":{"id":"1a1105dfcc9a7b54","repo":"spectreconsole/spectre.console","slug":"could-not-find-layout-name","errorCode":null,"errorMessage":"Could not find layout '{name}'","messagePattern":"Could not find layout '(.+?)'","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console/Widgets/Layout/Layout.cs","lineNumber":173,"sourceCode":"\n        var stack = new Stack<Layout>();\n        stack.Push(this);\n\n        while (stack.Count > 0)\n        {\n            var current = stack.Pop();\n            if (name.Equals(current.Name, StringComparison.OrdinalIgnoreCase))\n            {\n                return current;\n            }\n\n            foreach (var layout in current.GetChildren())\n            {\n                stack.Push(layout);\n            }\n        }\n\n        throw new InvalidOperationException($\"Could not find layout '{name}'\");\n    }\n\n    /// <summary>\n    /// Splits the layout into rows.\n    /// </summary>\n    /// <param name=\"children\">The layout to split into rows.</param>\n    /// <returns>The same instance so that multiple calls can be chained.</returns>\n    public Layout SplitRows(params Layout[] children)\n    {\n        Split(LayoutSplitter.Row, children);\n        return this;\n    }\n\n    /// <summary>\n    /// Splits the layout into columns.\n    /// </summary>\n    /// <param name=\"children\">The layout to split into columns.</param>\n    /// <returns>The same instance so that multiple calls can be chained.</returns>","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console/Widgets/Layout/Layout.cs#L155-L191","documentation":"Thrown by Layout.GetLayout after traversing the entire layout tree (via a stack-based DFS) without finding a child whose Name matches the requested name (case-insensitive). The name was valid but no matching node exists.","triggerScenarios":"Calling GetLayout with a name that does not correspond to any child layout in the current tree.","commonSituations":"Typo in the layout name, looking up a name before the layout tree is built, or referencing a layout that was never added via Split/SplitRows.","solutions":["Verify the exact name spelling against the names used when creating layouts.","Ensure the target layout was actually added as a child via a Split operation.","Enumerate children to confirm available names before lookup."],"exampleFix":"// before\nvar target = root.GetLayout(\"contnt\"); // typo: should be 'content'\n\n// after\nvar target = root.GetLayout(\"content\");","handlingStrategy":"try-catch","validationCode":"var allNames = CollectLayoutNames(root);\nif (!allNames.Contains(name)) throw new KeyNotFoundException($\"Layout '{name}' not found\");","typeGuard":null,"tryCatchPattern":"try { var child = root.GetLayout(name); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Could not find\"))\n{ /* handle missing layout, fall back */ }","preventionTips":["Verify layout names match those passed to the Layout(string) constructor.","Ensure target layouts were added via Split before lookup."],"tags":["layout","not-found","invalid-operation","spectre-console"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}