{"record":{"id":"e5b3d873e914da9d","repo":"spectreconsole/spectre.console","slug":"name-cannot-be-null-or-empty","errorCode":null,"errorMessage":"'name' cannot be null or empty.","messagePattern":"'name' cannot be null or empty\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console/Widgets/Layout/Layout.cs","lineNumber":153,"sourceCode":"        _splitter = LayoutSplitter.Null;\n        _children = [];\n        _renderable = renderable ?? new LayoutPlaceholder(this);\n        _ratio = 1;\n        _size = null;\n\n        Name = name;\n    }\n\n    /// <summary>\n    /// Gets a child layout by it's name.\n    /// </summary>\n    /// <param name=\"name\">The layout name.</param>\n    /// <returns>The specified child <see cref=\"Layout\"/>.</returns>\n    public Layout GetLayout(string name)\n    {\n        if (string.IsNullOrEmpty(name))\n        {\n            throw new ArgumentException($\"'{nameof(name)}' cannot be null or empty.\", nameof(name));\n        }\n\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        }","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console/Widgets/Layout/Layout.cs#L135-L171","documentation":"Thrown by Layout.GetLayout when the name argument is null or empty. A name is required to locate a child layout in the tree.","triggerScenarios":"Calling GetLayout(null) or GetLayout(string.Empty) or GetLayout(\"\") on a Layout instance.","commonSituations":"Passing a variable that was never assigned, reading a name from config that is missing, or passing an empty input from a search field.","solutions":["Ensure the name argument is a non-empty string before calling GetLayout.","Validate config values before use.","Use string.IsNullOrWhiteSpace to guard the input."],"exampleFix":"// before\nvar child = layout.GetLayout(userName); // userName may be null\n\n// after\nif (string.IsNullOrWhiteSpace(userName)) throw new ArgumentException(\"name required\");\nvar child = layout.GetLayout(userName);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(name)) throw new ArgumentException(\"Layout name cannot be empty\");\nvar child = layout.GetLayout(name);","typeGuard":"static bool IsValidLayoutName(string name) => !string.IsNullOrEmpty(name);","tryCatchPattern":null,"preventionTips":["Validate name inputs from config/UI before lookup.","Use string.IsNullOrWhiteSpace for defensive checks."],"tags":["layout","argument-validation","spectre-console"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}