iOfficeAI/OfficeCLI · error · InvalidOperationException

Plugin '{m.Name}' declares unsupported target '{m.Target}'.

Error message

Plugin '{m.Name}' declares unsupported target '{m.Target}'. Expected one of: docx, xlsx, pptx.

What it means

Thrown by PluginManifest.ResolveTargetFormat() when the manifest's target field is a non-null value that isn't docx, xlsx, or pptx (case-insensitive). A null target defaults safely to docx, so this only fires when the plugin explicitly declares an unrecognized format. This is an InvalidOperationException, not a CliException — it surfaces during plugin discovery/validation.

Source

Thrown at src/officecli/Core/Plugins/PluginManifest.cs:159

            return v;
        return Default > 0 ? Default : SafeDefault.Default;
    }
}

public static class PluginManifestExtensions
{
    /// <summary>
    /// Canonical target format name ("docx"/"xlsx"/"pptx"). Defaults to
    /// "docx" for plugins that omit the field. Throws if the manifest declares
    /// an unsupported target.
    /// </summary>
    public static string ResolveTargetFormat(this PluginManifest m)
    {
        var t = (m.Target ?? "docx").ToLowerInvariant();
        return t switch
        {
            "docx" or "xlsx" or "pptx" => t,
            _ => throw new InvalidOperationException(
                $"Plugin '{m.Name}' declares unsupported target '{m.Target}'. Expected one of: docx, xlsx, pptx."),
        };
    }

    /// <summary>
    /// File extension (with leading dot) for the plugin's target format.
    /// </summary>
    public static string ResolveTargetExtension(this PluginManifest m) =>
        "." + m.ResolveTargetFormat();

    /// <summary>
    /// Resolve the idle timeout for a verb, applying the safe default when the
    /// manifest is silent.
    /// </summary>
    public static int ResolveIdleTimeout(this PluginManifest m, string verb)
    {
        // Environment-variable escape hatch so a user hitting a hung plugin
        // can bypass the manifest budget without rebuilding the plugin:

View on GitHub (pinned to 1ced45e900)

Solutions

  1. Set the manifest's target field to one of: docx, xlsx, or pptx (case-insensitive).
  2. Remember: target is the NATIVE OOXML format the plugin produces, not the foreign input format. A .doc → .docx dump-reader should set target to 'docx', not 'doc'.
  3. If the plugin truly needs a target OfficeCLI doesn't support, the target field can be omitted entirely (defaults to 'docx') — but only if docx is correct.
  4. Run `plugins lint` or `plugins list` to validate the manifest before invoking the plugin.

Example fix

// before: manifest declares the foreign input format as target
{
  "name": "doc-reader",
  "target": "doc",
  "kinds": ["dump-reader"],
  "extensions": [".doc"]
}

// after: target is the native OOXML format the dump replays into
{
  "name": "doc-reader",
  "target": "docx",
  "kinds": ["dump-reader"],
  "extensions": [".doc"]
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate the target before calling ResolveTargetFormat
static readonly HashSet<string> ValidTargets = new() { "docx", "xlsx", "pptx" };

var target = (manifest.Target ?? "docx").ToLowerInvariant();
if (!ValidTargets.Contains(target))
    throw new ArgumentException($"Manifest target '{manifest.Target}' is invalid. Use: docx, xlsx, pptx, or omit (defaults to docx).");

// Safe to call:
var format = manifest.ResolveTargetFormat();

Type guard

static bool IsValidTargetFormat(PluginManifest m)
{
    var t = (m.Target ?? "docx").ToLowerInvariant();
    return t is "docx" or "xlsx" or "pptx";
}

Try / catch

try
{
    var ext = manifest.ResolveTargetExtension();
}
catch (InvalidOperationException ex) when (ex.Message.Contains("unsupported target"))
{
    // Manifest has a bad target field. Fix the manifest JSON.
    Console.Error.WriteLine($"Plugin '{manifest.Name}' has invalid target '{manifest.Target}'. Use docx/xlsx/pptx.");
}

Prevention

When it happens

Trigger: Calling PluginManifest.ResolveTargetFormat() or ResolveTargetExtension() on a manifest whose Target property is set to something like 'doc', 'pdf', 'odt', 'PPT', or a typo like 'docxx'. These extension methods are invoked during plugin registry loading, plugins list, and at format-handler invocation time.

Common situations: Plugin author sets target to the input format ('doc') instead of the native OOXML target ('docx'). Plugin author uses an abbreviation ('ppt' instead of 'pptx'). Plugin was written for a future format OfficeCLI doesn't support yet. Typo in the manifest JSON. Plugin declares a non-OOXML format like 'pdf' or 'odt' as its target.

Related errors


AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13). Data as JSON: /api/errors/39b88eebc8a5fd21. Report an issue: GitHub.