{"record":{"id":"1deed893a9d325aa","repo":"iOfficeAI/OfficeCLI","slug":"unsupported-file-type-ext-supported-docx-x","errorCode":null,"errorMessage":"Unsupported file type: {ext}. Supported: .docx, .xlsx, .pptx, or any extension served by an installed format-handler plugin that implements `create`.","messagePattern":"Unsupported file type: (.+?)\\. Supported: \\.docx, \\.xlsx, \\.pptx, or any extension served by an installed format-handler plugin that implements `create`\\.","errorType":"validation","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/officecli/BlankDocCreator.cs","lineNumber":31,"sourceCode":"public static class BlankDocCreator\n{\n    public static void Create(string path, string? locale = null, bool minimal = false)\n    {\n        var ext = Path.GetExtension(path).ToLowerInvariant();\n        switch (ext)\n        {\n            case \".xlsx\":\n                CreateExcel(path, locale);\n                break;\n            case \".docx\":\n                CreateWord(path, locale, minimal);\n                break;\n            case \".pptx\":\n                CreatePowerPoint(path, locale);\n                break;\n            default:\n                if (TryCreateViaPlugin(path, ext)) break;\n                throw new NotSupportedException($\"Unsupported file type: {ext}. Supported: .docx, .xlsx, .pptx, or any extension served by an installed format-handler plugin that implements `create`.\");\n        }\n    }\n\n    /// <summary>\n    /// Delegate creation of an unknown extension to a registered format-handler\n    /// plugin, if one exists for that extension and exposes a `create &lt;path&gt;`\n    /// CLI subcommand. Returns <c>true</c> if a plugin was found and produced\n    /// the file successfully. Generic per plugins/plugin-protocol.md — keeps\n    /// BlankDocCreator format-agnostic; any plugin that implements the\n    /// `create` subcommand on its executable participates.\n    /// </summary>\n    private static bool TryCreateViaPlugin(string path, string ext)\n    {\n        var plugin = OfficeCli.Core.Plugins.PluginRegistry.FindFor(\n            OfficeCli.Core.Plugins.PluginKind.FormatHandler, ext);\n        if (plugin is null) return false;\n        var psi = new System.Diagnostics.ProcessStartInfo\n        {","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/BlankDocCreator.cs#L13-L49","documentation":"Thrown by BlankDocCreator.Create when the target path's extension is not .docx/.xlsx/.pptx and no format-handler plugin claimed it via TryCreateViaPlugin. It is a NotSupportedException that surfaces when `officecli create <path>` (or any path that routes to blank-doc creation) is asked to produce a format OfficeCLI has no built-in or plugin writer for.","triggerScenarios":"`officecli create report.pdf`, `officecli create notes.odt`, `officecli create data.csv`, or `officecli create slide.key` when no plugin registered for that extension. The switch in Create() falls to default, TryCreateViaPlugin returns false (PluginRegistry.FindFor finds nothing), and the throw fires.","commonSituations":"User assumes `create` works for any Office-adjacent format; a script passes a user-supplied filename without validating the extension first; a plugin that should handle the format is not installed or not on PATH; the extension has different casing/whitespace that bypassed ToLowerInvariant (rare, since it lowercases).","solutions":["Change the target extension to a supported one: .docx, .xlsx, or .pptx.","Install a format-handler plugin that implements the `create` subcommand for the desired extension (see plugins/plugin-protocol.md), then retry.","Pre-validate the extension in your wrapper script before calling create."],"exampleFix":"# before\nofficecli create report.pdf\n\n# after\nofficecli create report.docx","handlingStrategy":"validation","validationCode":"// Validate the extension is supported (or plugin-backed) before calling Create.\nstatic readonly HashSet<string> BuiltIn = new(StringComparer.OrdinalIgnoreCase) { \".docx\", \".xlsx\", \".pptx\" };\nvar ext = Path.GetExtension(path);\nif (!BuiltIn.Contains(ext) && !PluginHandler.IsRegistered(ext))\n    throw new InvalidOperationException($\"Refusing to create unsupported extension {ext}; use .docx/.xlsx/.pptx\");\nBlankDocCreator.Create(path, locale);","typeGuard":"// Guard: is this extension one Create can handle?\nstatic bool IsCreatable(string path) =>\n    Path.GetExtension(path).ToLowerInvariant() is \".docx\" or \".xlsx\" or \".pptx\";\n// (add a plugin-registry check for custom extensions)","tryCatchPattern":null,"preventionTips":["Constrain user-supplied filenames to the three supported extensions in your UI/script before calling create.","For custom formats, register a format-handler plugin implementing the `create` subcommand before exposing that extension to users.","Whitelist extensions at the input boundary rather than relying on the runtime error."],"tags":["file-format","create","plugin","notsupported"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}