{"record":{"id":"333ff53490b4eceb","repo":"microsoft/aspire","slug":"the-argument-arg-cannot-be-configured-with","errorCode":null,"errorMessage":"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}","messagePattern":"The argument '(.+?)' cannot be configured with WithDenoRuntimeArgs because (.+?) already emits (.+?), and Deno rejects those arguments when they are combined\\. (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.JavaScript/DenoHostingExtensions.cs","lineNumber":749,"sourceCode":"        bool includeImportMap,\n        bool includeDevelopmentFlags)\n    {\n        foreach (var arg in deno.RuntimeArgs)\n        {\n            // Both spellings reach Deno's parser: \"--port 3000\" (separate value) and \"--port=3000\".\n            var name = arg.AsSpan();\n            var separator = name.IndexOf('=');\n            if (separator >= 0)\n            {\n                name = name[..separator];\n            }\n\n            if (GetManagedDenoFlagConflict(name, deno, emitsServeEndpoint, includeImportMap, includeDevelopmentFlags) is not { } conflict)\n            {\n                continue;\n            }\n\n            throw new InvalidOperationException(\n                $\"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}\");\n        }\n    }\n\n    private static (string ManagedFlag, string Source, string Remedy)? GetManagedDenoFlagConflict(\n        ReadOnlySpan<char> name,\n        DenoCommandLineAnnotation deno,\n        bool emitsServeEndpoint,\n        bool includeImportMap,\n        bool includeDevelopmentFlags)\n    {\n        if (emitsServeEndpoint && (name.Equals(\"--host\", StringComparison.Ordinal) || name.Equals(\"--port\", StringComparison.Ordinal)))\n        {\n            return (\"--host and --port from the resource's endpoint\", nameof(WithDenoServe), \"Configure the endpoint instead, for example WithHttpEndpoint(port: 5005).\");\n        }\n\n        // -c is an alias for --config, while --no-config is mutually exclusive with it.\n        if (!string.IsNullOrEmpty(deno.ConfigFile) &&","sourceCodeStart":731,"sourceCodeEnd":767,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.JavaScript/DenoHostingExtensions.cs#L731-L767","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Remove the duplicated argument from WithDenoRuntimeArgs and configure it via its dedicated API (WithDenoInspect, WithDenoUnstable, WithDenoServeEndpoint, etc.).","Follow the conflict.Remedy text in the message, which states exactly which feature already emits the flag.","Audit all WithDenoRuntimeArgs call sites for strings starting with '--inspect' or '--unstable-' and route them to the proper builder method.","Only keep genuinely free-form arguments (e.g. script positional args) in WithDenoRuntimeArgs."],"exampleFix":"// before\nresource.WithDenoInspect().WithDenoRuntimeArgs(\"--inspect-brk\");\n// after\nresource.WithDenoInspect(DenoInspectMode.InspectBrk);","handlingStrategy":"validation","validationCode":"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.\");","typeGuard":null,"tryCatchPattern":"try { app.Run(); } catch (InvalidOperationException ex) when (ex.Message.Contains(nameof(WithDenoRuntimeArgs))) { /* drop the conflicting runtime arg and reconfigure */ }","preventionTips":["Configure inspector/unstable/serve/import-map features only through their dedicated WithDeno* methods","Reserve WithDenoRuntimeArgs for flags Aspire does not manage","Search the codebase for hardcoded '--inspect'/'--unstable-' strings during migration"],"tags":["invalid-operation-exception","deno","conflicting-flags","cli-arguments"],"backgroundTag":"conflicting-config-options","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}