{"record":{"id":"0d195906b2554e77","repo":"iOfficeAI/OfficeCLI","slug":"invalid-value-0d1959","errorCode":"invalid_value","errorMessage":"Unknown format: {format}. Use 'csv' or 'tsv'","messagePattern":"Unknown format: (.+?)\\. Use 'csv' or 'tsv'","errorType":"exception","errorClass":"CliException","httpStatus":null,"severity":"error","filePath":"src/officecli/CommandBuilder.Import.cs","lineNumber":98,"sourceCode":"            }\n            else\n            {\n                throw new CliException(\"Either --file or --stdin must be specified\")\n                {\n                    Code = \"missing_argument\",\n                    Suggestion = \"Use --file <path> to specify a CSV/TSV file, or --stdin to read from standard input\"\n                };\n            }\n\n            // Determine delimiter: --format flag > file extension > default csv\n            char delimiter = ',';\n            if (!string.IsNullOrEmpty(format))\n            {\n                delimiter = format.ToLowerInvariant() switch\n                {\n                    \"tsv\" => '\\t',\n                    \"csv\" => ',',\n                    _ => throw new CliException($\"Unknown format: {format}. Use 'csv' or 'tsv'\")\n                    {\n                        Code = \"invalid_value\",\n                        ValidValues = [\"csv\", \"tsv\"]\n                    }\n                };\n            }\n            else if (source != null)\n            {\n                var sourceExt = Path.GetExtension(source.FullName).ToLowerInvariant();\n                if (sourceExt == \".tsv\" || sourceExt == \".tab\")\n                    delimiter = '\\t';\n            }\n\n            // Release any running resident's file lock before direct-open (import bypasses resident)\n            ResidentClient.SendClose(file.FullName);\n            using var handler = new OfficeCli.Handlers.ExcelHandler(file.FullName, editable: true);\n            var msg = handler.Import(parentPath, csvContent, delimiter, header, startCell);\n            if (json)","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/CommandBuilder.Import.cs#L80-L116","documentation":"The --format flag only accepts 'csv' (comma) or 'tsv' (tab). Any other value (e.g. 'json', 'xlsx') is rejected here with the valid set surfaced via ValidValues.","triggerScenarios":"'officecli import out.xlsx --file data.csv --format json' or any --format value outside {csv, tsv}.","commonSituations":"Confusing the source file format with the target workbook format; passing the data's logical type instead of the delimiter name.","solutions":["Use --format csv or --format tsv.","If omitted, format is inferred from the source extension (.tsv/.tab -> tab, else comma)."],"exampleFix":"// before\nofficecli import out.xlsx --file data.csv --format json\n// after\nofficecli import out.xlsx --file data.csv --format csv","handlingStrategy":"validation","validationCode":"static readonly HashSet<string> ImportFormats = new(StringComparer.OrdinalIgnoreCase) { \"csv\", \"tsv\" };\nif (format is not null && !ImportFormats.Contains(format))\n    throw new ArgumentException($\"--format must be csv or tsv, got '{format}'.\");","typeGuard":"static bool IsValidImportFormat(string? f) =>\n    f is null || f.Equals(\"csv\", StringComparison.OrdinalIgnoreCase)\n              || f.Equals(\"tsv\", StringComparison.OrdinalIgnoreCase);","tryCatchPattern":null,"preventionTips":["--format names the delimiter, not the data schema.","Let the source extension infer when unsure (.tsv/.tab -> tab)."],"tags":["import","format","invalid-value","csv","tsv"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}