iOfficeAI/OfficeCLI · error · NotSupportedException
Unsupported file type: {ext}. Supported: .docx, .xlsx, .pptx
Error message
Unsupported file type: {ext}. Supported: .docx, .xlsx, .pptx, or any extension served by an installed format-handler plugin that implements `create`. What it means
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.
Source
Thrown at src/officecli/BlankDocCreator.cs:31
public static class BlankDocCreator
{
public static void Create(string path, string? locale = null, bool minimal = false)
{
var ext = Path.GetExtension(path).ToLowerInvariant();
switch (ext)
{
case ".xlsx":
CreateExcel(path, locale);
break;
case ".docx":
CreateWord(path, locale, minimal);
break;
case ".pptx":
CreatePowerPoint(path, locale);
break;
default:
if (TryCreateViaPlugin(path, ext)) break;
throw new NotSupportedException($"Unsupported file type: {ext}. Supported: .docx, .xlsx, .pptx, or any extension served by an installed format-handler plugin that implements `create`.");
}
}
/// <summary>
/// Delegate creation of an unknown extension to a registered format-handler
/// plugin, if one exists for that extension and exposes a `create <path>`
/// CLI subcommand. Returns <c>true</c> if a plugin was found and produced
/// the file successfully. Generic per plugins/plugin-protocol.md — keeps
/// BlankDocCreator format-agnostic; any plugin that implements the
/// `create` subcommand on its executable participates.
/// </summary>
private static bool TryCreateViaPlugin(string path, string ext)
{
var plugin = OfficeCli.Core.Plugins.PluginRegistry.FindFor(
OfficeCli.Core.Plugins.PluginKind.FormatHandler, ext);
if (plugin is null) return false;
var psi = new System.Diagnostics.ProcessStartInfo
{View on GitHub (pinned to 1ced45e900)
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.
Example fix
# before officecli create report.pdf # after officecli create report.docx
Defensive patterns
Strategy: validation
Validate before calling
// Validate the extension is supported (or plugin-backed) before calling Create.
static readonly HashSet<string> BuiltIn = new(StringComparer.OrdinalIgnoreCase) { ".docx", ".xlsx", ".pptx" };
var ext = Path.GetExtension(path);
if (!BuiltIn.Contains(ext) && !PluginHandler.IsRegistered(ext))
throw new InvalidOperationException($"Refusing to create unsupported extension {ext}; use .docx/.xlsx/.pptx");
BlankDocCreator.Create(path, locale); Type guard
// Guard: is this extension one Create can handle?
static bool IsCreatable(string path) =>
Path.GetExtension(path).ToLowerInvariant() is ".docx" or ".xlsx" or ".pptx";
// (add a plugin-registry check for custom extensions) Prevention
- 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.
When it happens
Trigger: `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.
Common situations: 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).
Related errors
- plugin_create_failed
- unsupported_format
- Source range has no data
- Source range has no data rows
- Workbook is missing
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/1deed893a9d325aa.
Report an issue: GitHub.