{"record":{"id":"3ba5605881c09ee2","repo":"microsoft/aspire","slug":"invalid-value-dcppublisherconfiguration-nameof-options","errorCode":null,"errorMessage":"Invalid value \"{dcpPublisherConfiguration[nameof(options.DependencyCheckTimeout)]}\" for \"--dcp-dependency-check-timeout\". Expected an integer value.","messagePattern":"Invalid value \"(.+?)\" for \"--dcp-dependency-check-timeout\"\\. Expected an integer value\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/Dcp/DcpOptions.cs","lineNumber":324,"sourceCode":"\n        if (!string.IsNullOrEmpty(dcpPublisherConfiguration[nameof(options.ContainerRuntime)]))\n        {\n            options.ContainerRuntime = dcpPublisherConfiguration[nameof(options.ContainerRuntime)];\n        }\n        else\n        {\n            options.ContainerRuntime = configuration.GetString(KnownConfigNames.ContainerRuntime, KnownConfigNames.Legacy.ContainerRuntime);\n        }\n\n        if (!string.IsNullOrEmpty(dcpPublisherConfiguration[nameof(options.DependencyCheckTimeout)]))\n        {\n            if (int.TryParse(dcpPublisherConfiguration[nameof(options.DependencyCheckTimeout)], out var timeout))\n            {\n                options.DependencyCheckTimeout = timeout;\n            }\n            else\n            {\n                throw new InvalidOperationException($\"Invalid value \\\"{dcpPublisherConfiguration[nameof(options.DependencyCheckTimeout)]}\\\" for \\\"--dcp-dependency-check-timeout\\\". Expected an integer value.\");\n            }\n        }\n        else\n        {\n            options.DependencyCheckTimeout = configuration.GetValue(KnownConfigNames.DependencyCheckTimeout, KnownConfigNames.Legacy.DependencyCheckTimeout, options.DependencyCheckTimeout);\n        }\n\n        options.KubernetesConfigReadRetryCount = dcpPublisherConfiguration.GetValue(nameof(options.KubernetesConfigReadRetryCount), options.KubernetesConfigReadRetryCount);\n        options.KubernetesConfigReadRetryIntervalMilliseconds = dcpPublisherConfiguration.GetValue(nameof(options.KubernetesConfigReadRetryIntervalMilliseconds), options.KubernetesConfigReadRetryIntervalMilliseconds);\n\n        if (!string.IsNullOrEmpty(dcpPublisherConfiguration[nameof(options.ResourceNameSuffix)]))\n        {\n            options.ResourceNameSuffix = dcpPublisherConfiguration[nameof(options.ResourceNameSuffix)];\n        }\n\n        options.RandomizePorts = dcpPublisherConfiguration.GetValue(nameof(options.RandomizePorts), options.RandomizePorts);\n        options.ProxylessEndpointPortRangeStart = dcpPublisherConfiguration.GetValue(nameof(options.ProxylessEndpointPortRangeStart), options.ProxylessEndpointPortRangeStart);\n        options.ProxylessEndpointPortRangeEnd = dcpPublisherConfiguration.GetValue(nameof(options.ProxylessEndpointPortRangeEnd), options.ProxylessEndpointPortRangeEnd);","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/Dcp/DcpOptions.cs#L306-L342","documentation":"DcpOptions.Configure parses the --dcp-dependency-check-timeout configuration value and requires it to be a valid integer. When the configured string exists but cannot be parsed by int.TryParse, it throws this InvalidOperationException instead of silently ignoring the value. This fails fast so a typo does not silently produce a default timeout.","triggerScenarios":"Setting --dcp-dependency-check-timeout (or DcpPublisher:DependencyCheckTimeout config key) to a non-integer string such as \"30s\", \"00:00:30\", \"thirty\", or a value with whitespace/units.","commonSituations":"Passing a TimeSpan-formatted value like \"00:01:00\" or \"90s\" on the command line or in appsettings.json expecting it to be parsed as a duration; copy-pasting values with trailing characters.","solutions":["Set --dcp-dependency-check-timeout to a plain integer of seconds, e.g. --dcp-dependency-check-timeout 90","Remove the flag entirely to fall back to the DependencyCheckTimeout default or the KnownConfigNames.DependencyCheckTimeout value","Check appsettings/environment config for the DcpPublisher:DependencyCheckTimeout key and fix it to an integer"],"exampleFix":"// before\ndotnet run --dcp-dependency-check-timeout 90s\n// after\ndotnet run --dcp-dependency-check-timeout 90","handlingStrategy":"validation","validationCode":"var value = configuration[\"DcpPublisher:DependencyCheckTimeout\"];\nif (value is not null && !int.TryParse(value, out _))\n{\n    throw new FormatException($\"'{value}' is not a valid integer for --dcp-dependency-check-timeout.\");\n}","typeGuard":"bool IsValidTimeoutValue(string? v) => v is null || int.TryParse(v, out _);","tryCatchPattern":"try\n{\n    options.Configure(configuration);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"--dcp-dependency-check-timeout\"))\n{\n    // Fall back to default timeout or surface a corrected value.\n    options.DependencyCheckTimeout = 60;\n}","preventionTips":["Always pass whole seconds as a plain integer, never \"90s\" or TimeSpan strings","Validate config values in CI before launching the AppHost","Prefer omitting the flag to use the built-in default"],"tags":["configuration","cli","dcp","parsing"],"backgroundTag":"invalid-env-var-value","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}