{"record":{"id":"70c6a6c47af5bad7","repo":"iOfficeAI/OfficeCLI","slug":"pivot-name-must-not-be-whitespace-only","errorCode":null,"errorMessage":"pivot name must not be whitespace-only","messagePattern":"pivot name must not be whitespace-only","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/PivotTableHelper.cs","lineNumber":181,"sourceCode":"\n    /// <summary>\n    /// Validate a user-supplied pivot table name and return the trimmed value.\n    /// Throws ArgumentException for empty, whitespace-only, control-character,\n    /// or over-255-character names. Does NOT check workbook-level uniqueness\n    /// (that is the caller's responsibility).\n    /// R16-2: extracted from CreatePivotTable so SetPivotTableProperties can\n    /// reuse the same validation — previously Set accepted empty/whitespace\n    /// names without any check.\n    /// </summary>\n    private static string ValidatePivotName(string name)\n    {\n        // Empty string is rejected — a blank name is always an error.\n        if (string.IsNullOrEmpty(name))\n            throw new ArgumentException(\"pivot name must not be empty\");\n        var trimmed = name.Trim();\n        // Whitespace-only names are rejected — R8-4.\n        if (trimmed.Length == 0)\n            throw new ArgumentException(\"pivot name must not be whitespace-only\");\n        // ASCII control characters are rejected — R8-5.\n        foreach (var ch in trimmed)\n        {\n            if (ch < 0x20 || ch == 0x7F)\n                throw new ArgumentException(\"pivot name contains invalid control characters\");\n        }\n        // 255-character limit — R11-4.\n        if (trimmed.Length > 255)\n            throw new ArgumentException(\"pivot name exceeds 255-character limit\");\n        return trimmed;\n    }\n\n    /// <summary>\n    /// Canonical key set recognized by the pivot Add / Set pipeline. Any\n    /// property whose NORMALIZED key is not in this set is reported as\n    /// UNSUPPORTED (Add: stderr warning; Set: returned unsupported list).\n    /// Must stay in sync with the switch in SetPivotTableProperties and\n    /// every properties lookup in CreatePivotTable.","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/PivotTableHelper.cs#L163-L199","documentation":"Thrown by ValidatePivotName when the name is non-empty but consists entirely of whitespace characters (Trim() yields length 0). OOXML pivot names are trimmed before use, so a whitespace-only string is effectively blank. This is R8-4: whitespace-only names are explicitly rejected rather than silently accepted.","triggerScenarios":"Calling Add pivot name='   ' or Set pivot name='\\t' where the entire string is spaces, tabs, or other whitespace.","commonSituations":"User input that is just spaces; copy-paste that introduced only whitespace; form field left as spaces instead of empty; tab characters passed as the name.","solutions":["Provide a name with at least one non-whitespace character.","Trim user input in your own code and reject it if empty after trimming.","Substitute a meaningful default name when the input trims to empty."],"exampleFix":"// before\nSet pivot name='   '\n// after\nSet pivot name='SalesPivot'","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(pivotName))\n    throw new ArgumentException(\"Pivot name must not be empty or whitespace-only.\");","typeGuard":"static bool IsValidPivotName(string name) =>\n    !string.IsNullOrEmpty(name) && name.Trim().Length > 0;","tryCatchPattern":null,"preventionTips":["Trim user input and reject it if empty after trimming.","Provide a default name when the input is whitespace-only.","Validate names in your form/input layer before calling the API."],"tags":["pivot","excel","naming","validation","whitespace"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}