microsoft/aspire · error · InvalidOperationException

The argument ' ' cannot be configured with…

Error message

The argument '{arg}' cannot be configured with WithDenoRuntimeArgs because {conflict.Source} already emits {conflict.ManagedFlag}, and Deno rejects those arguments when they are combined. {conflict.Remedy}

What it means

BuildDenoArgs detects when a user-supplied runtime argument (e.g. '--inspect', '--unstable-*') duplicates a flag that Aspire already emits because of annotations (WithDenoInspect, WithDenoUnstable, serve endpoints, import maps, dev flags). Deno rejects such duplicate/combined flags, so the library throws InvalidOperationException naming the conflicting flag, its source, and the remedy.

Solutions

  1. Remove the duplicated argument from WithDenoRuntimeArgs and configure it via its dedicated API (WithDenoInspect, WithDenoUnstable, WithDenoServeEndpoint, etc.).
  2. Follow the conflict.Remedy text in the message, which states exactly which feature already emits the flag.
  3. Audit all WithDenoRuntimeArgs call sites for strings starting with '--inspect' or '--unstable-' and route them to the proper builder method.
  4. Only keep genuinely free-form arguments (e.g. script positional args) in WithDenoRuntimeArgs.

Example fix

// before
resource.WithDenoInspect().WithDenoRuntimeArgs("--inspect-brk");
// after
resource.WithDenoInspect(DenoInspectMode.InspectBrk);
Defensive patterns

Strategy: validation

Validate before calling

foreach (var a in runtimeArgs) if (a.StartsWith("--inspect") || a.StartsWith("--unstable-")) throw new ArgumentException($"'{a}' is managed by a dedicated WithDeno* API; remove it from runtime args.");

Try / catch

try { app.Run(); } catch (InvalidOperationException ex) when (ex.Message.Contains(nameof(WithDenoRuntimeArgs))) { /* drop the conflicting runtime arg and reconfigure */ }

Prevention

When it happens

Trigger: Calling WithDenoRuntimeArgs("--inspect", ...) while WithDenoInspect is also configured; passing '--unstable-kv' via runtime args while WithDenoUnstable already adds it; enabling dev flags/import maps/serve endpoints that emit a flag the user also passes manually.

Common situations: Migrating an existing Deno launch script into Aspire and keeping all CLI flags as runtime args; enabling the inspector for debugging while another config source also sets it; incremental Aspire adoption where flags were added twice via different APIs.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/333ff53490b4eceb. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.JavaScript/DenoHostingExtensions.cs:749

        bool includeImportMap,
        bool includeDevelopmentFlags)
    {
        foreach (var arg in deno.RuntimeArgs)
        {
            // Both spellings reach Deno's parser: "--port 3000" (separate value) and "--port=3000".
            var name = arg.AsSpan();
            var separator = name.IndexOf('=');
            if (separator >= 0)
            {
                name = name[..separator];
            }

            if (GetManagedDenoFlagConflict(name, deno, emitsServeEndpoint, includeImportMap, includeDevelopmentFlags) is not { } conflict)
            {
                continue;
            }

            throw new InvalidOperationException(
                $"The argument '{arg}' cannot be configured with {nameof(WithDenoRuntimeArgs)} because {conflict.Source} already emits {conflict.ManagedFlag}, and Deno rejects those arguments when they are combined. {conflict.Remedy}");
        }
    }

    private static (string ManagedFlag, string Source, string Remedy)? GetManagedDenoFlagConflict(
        ReadOnlySpan<char> name,
        DenoCommandLineAnnotation deno,
        bool emitsServeEndpoint,
        bool includeImportMap,
        bool includeDevelopmentFlags)
    {
        if (emitsServeEndpoint && (name.Equals("--host", StringComparison.Ordinal) || name.Equals("--port", StringComparison.Ordinal)))
        {
            return ("--host and --port from the resource's endpoint", nameof(WithDenoServe), "Configure the endpoint instead, for example WithHttpEndpoint(port: 5005).");
        }

        // -c is an alias for --config, while --no-config is mutually exclusive with it.
        if (!string.IsNullOrEmpty(deno.ConfigFile) &&

View on GitHub (pinned to 25830f84bd)