{"record":{"id":"ad542f9c0665357d","repo":"iOfficeAI/OfficeCLI","slug":"unsupported-type-ad542f","errorCode":"unsupported_type","errorMessage":"'import' batch command is only supported for .xlsx files","messagePattern":"'import' batch command is only supported for \\.xlsx files","errorType":"exception","errorClass":"CliException","httpStatus":null,"severity":"error","filePath":"src/officecli/CommandBuilder.cs","lineNumber":1110,"sourceCode":"                        {\n                            string? addScope = handler is OfficeCli.Handlers.ExcelHandler ? \"excel\"\n                                : handler is OfficeCli.Handlers.PowerPointHandler ? \"pptx\" : null;\n                            hint = FormatUnsupported(addUnsupported, addScope);\n                        }\n                        if (hint != null) addMsg += \"\\nWARNING: \" + hint;\n                    }\n                    return addMsg;\n                }\n            }\n            case \"import\":\n            {\n                // CSV/TSV bulk import — batch counterpart of the standalone\n                // `officecli import` command (CommandBuilder.Import.cs). The\n                // CSV content rides the item's `text` field; `parent` is the\n                // sheet path. This is the value-baseline carrier for\n                // `dump --format batch` on .xlsx (ExcelBatchEmitter).\n                if (handler is not OfficeCli.Handlers.ExcelHandler importXl)\n                    throw new CliException(\"'import' batch command is only supported for .xlsx files\")\n                        { Code = \"unsupported_type\" };\n                var importParent = item.Parent ?? item.Path;\n                if (string.IsNullOrEmpty(importParent))\n                    throw new ArgumentException(\"'import' command requires 'parent' field (sheet path). Example: {\\\"command\\\": \\\"import\\\", \\\"parent\\\": \\\"/Sheet1\\\", \\\"text\\\": \\\"a,b\\\\n1,2\\\"}\");\n                if (item.Text == null)\n                    throw new ArgumentException(\"'import' command requires 'text' field with the CSV/TSV content.\");\n                // CONSISTENCY(import-vocabulary): props mirror the standalone\n                // command's options — format=csv|tsv, header, start-cell.\n                char importDelim = ',';\n                if (props.TryGetValue(\"format\", out var importFmt) && !string.IsNullOrEmpty(importFmt))\n                {\n                    importDelim = importFmt.ToLowerInvariant() switch\n                    {\n                        \"tsv\" => '\\t',\n                        \"csv\" => ',',\n                        _ => throw new CliException($\"Unknown format: {importFmt}. Use 'csv' or 'tsv'\")\n                            { Code = \"invalid_value\", ValidValues = [\"csv\", \"tsv\"] },\n                    };","sourceCodeStart":1092,"sourceCodeEnd":1128,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/CommandBuilder.cs#L1092-L1128","documentation":"Thrown by ExecuteBatchItem for a batch \"import\" step (CSV/TSV bulk import) when the active handler is not the ExcelHandler. Import is the value-baseline carrier for ExcelBatchEmitter and only makes sense for spreadsheets, so it is rejected for Word/PowerPoint. CliException Code=\"unsupported_type\".","triggerScenarios":"{\"command\":\"import\",\"parent\":\"/Sheet1\",\"text\":\"a,b\\n1,2\"} run against a .docx or .pptx; a dump --format batch from an .xlsx replayed against a non-Excel file; a generic batch driver that always emits import steps.","commonSituations":"A reusable batch script applied to the wrong file type; cross-type dump/replay; a generator that does not branch on extension before emitting import.","solutions":["Only run import batch steps against .xlsx files.","Skip import steps when the document is not Excel.","Branch the batch emitter on file extension/handler type before producing import steps.","For non-Excel files, use set/add instead of import to populate content."],"exampleFix":"// before: import step run against report.docx\n{\"command\":\"import\",\"parent\":\"/Sheet1\",\"text\":\"a,b\\n1,2\"}\n// after: run the same step only against data.xlsx\nofficecli batch data.xlsx items.json","handlingStrategy":"validation","validationCode":"// Only emit import steps for Excel workbooks.\nif (!path.EndsWith(\".xlsx\", StringComparison.OrdinalIgnoreCase))\n    continue;   // skip import for non-Excel files","typeGuard":"static bool CanImport(IDocumentHandler h) => h is ExcelHandler;","tryCatchPattern":"try { ExecuteBatchItem(handler, item, json); }\ncatch (CliException ex) when (ex.Code == \"unsupported_type\")\n{ /* skip import step for this non-Excel document */ }","preventionTips":["Branch the batch emitter on extension before producing import steps.","Reserve import for .xlsx; use set/add for Word/PowerPoint.","Type-check the handler before issuing import."],"tags":["batch","import","excel","unsupported-type","validation","officecli"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}