{"record":{"id":"53de622c93624ff9","repo":"iOfficeAI/OfficeCLI","slug":"invalid-layout-mode-valid-compact-outline","errorCode":null,"errorMessage":"invalid layout: '{mode}'. Valid: compact, outline, tabular","messagePattern":"invalid layout: '(.+?)'\\. Valid: compact, outline, tabular","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/PivotTableHelper.cs","lineNumber":595,"sourceCode":"\n    /// <summary>\n    /// Parse layout property into the thread-static scope. Supports:\n    ///   layout=compact|outline|tabular\n    /// Returns a scope that restores the previous value on Dispose.\n    /// </summary>\n    private static readonly HashSet<string> _validLayoutModes = new(StringComparer.OrdinalIgnoreCase)\n    {\n        \"compact\", \"outline\", \"tabular\"\n    };\n\n    private static IDisposable PushLayoutMode(Dictionary<string, string> properties)\n    {\n        var prev = _layoutMode;\n        if (properties.TryGetValue(\"layout\", out var mode) && !string.IsNullOrWhiteSpace(mode))\n        {\n            var normalized = mode.Trim().ToLowerInvariant();\n            if (!_validLayoutModes.Contains(normalized))\n                throw new ArgumentException(\n                    $\"invalid layout: '{mode}'. Valid: compact, outline, tabular\");\n            _layoutMode = normalized;\n        }\n        return new LayoutModeScope(prev);\n    }\n\n    private sealed class LayoutModeScope : IDisposable\n    {\n        private readonly string? _prev;\n        public LayoutModeScope(string? prev) { _prev = prev; }\n        public void Dispose() { _layoutMode = _prev; }\n    }\n\n    // CONSISTENCY(thread-static-pivot-opts): repeatItemLabels — \"Repeat All\n    // Item Labels\" in Excel's Report Layout menu. When true, outer row axis\n    // labels are repeated on every leaf row instead of appearing only once\n    // at the top of each group. OOXML: fillDownLabelsDefault on x14:pivotTableDefinition.\n    [ThreadStatic] private static bool? _repeatItemLabels;","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/PivotTableHelper.cs#L577-L613","documentation":"Thrown by PushLayoutMode when the 'layout' property contains a token not in _validLayoutModes {compact, outline, tabular}. These correspond to Excel's three pivot layout report formats. Unknown layout tokens are rejected up front (CONSISTENCY strict-enums) rather than silently defaulting.","triggerScenarios":"Calling Add/Set pivot layout='tabular' is valid, but layout='flat', layout='default', layout='grid', or any token outside the three accepted values triggers this.","commonSituations":"Using Excel UI terminology that does not match the library's token (e.g. 'flat' instead of 'compact'); typo like layout='oultine'; assuming 'grid' is an alias for 'tabular'.","solutions":["Use one of: compact, outline, tabular.","If unsure which to use, omit the layout property to accept the default (compact).","Check spelling — case-insensitive but must exactly match one of the three tokens."],"exampleFix":"// before\nSet pivot layout='flat'\n// after\nSet pivot layout='compact'","handlingStrategy":"validation","validationCode":"var validLayouts = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { \"compact\", \"outline\", \"tabular\" };\nif (!string.IsNullOrWhiteSpace(layout) && !validLayouts.Contains(layout.Trim().ToLowerInvariant()))\n    throw new ArgumentException($\"Invalid layout '{layout}'. Valid: compact, outline, tabular.\");","typeGuard":"static readonly HashSet<string> ValidLayouts =\n    new(StringComparer.OrdinalIgnoreCase) { \"compact\", \"outline\", \"tabular\" };\nstatic bool IsValidLayout(string mode) =>\n    string.IsNullOrWhiteSpace(mode) || ValidLayouts.Contains(mode.Trim().ToLowerInvariant());","tryCatchPattern":null,"preventionTips":["Use one of: compact, outline, tabular.","Omit the layout property to accept the default.","Do not use synonyms like 'flat' or 'grid'."],"tags":["pivot","excel","layout","enum","validation","input-validation"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}