microsoft/aspire · error · ArgumentException

The value ' ' is not a valid HTTP version. Expected format…

Error message

The value '{config.Version}' is not a valid HTTP version. Expected format is 'major.minor', for example '1.1' or '2.0'.

What it means

Thrown by YarpCluster.ToForwarderRequestConfig when config.Version is non-empty but not parseable as a System.Version (major.minor). YARP forwards this value as the HTTP request version, so it must be like "1.1", "2.0", or "3.0". The library validates the string early to fail fast instead of YARP failing later.

Solutions

  1. Pass a valid major.minor string, e.g. Version = "1.1" or Version = "2.0".
  2. If the version is optional, set Version to null or omit it instead of an empty placeholder string.
  3. Normalize inputs with Version.TryParse before constructing YarpForwarderRequestConfig.

Example fix

// before
new YarpForwarderRequestConfig { Version = "http/2" }
// after
new YarpForwarderRequestConfig { Version = "2.0" }
Defensive patterns

Strategy: validation

Validate before calling

if (!string.IsNullOrWhiteSpace(config.Version) && !Version.TryParse(config.Version, out _))
{
    throw new InvalidOperationException($"'{config.Version}' is not a valid HTTP version; use e.g. '1.1' or '2.0'.");
}

Prevention

When it happens

Trigger: Calling cluster.WithForwarderRequestConfig(...) with a YarpForwarderRequestConfig whose Version string is e.g. "2", "v1.1", "1.1.1.1" with an invalid segment, "HTTP/2", or "two".

Common situations: Copying a version string from an HttpClient property like "2.0" with surrounding text; using "1.0.1" full-build style versions; writing "http/2" out of habit; typos like "1,1".

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at src/Aspire.Hosting.Yarp/ConfigurationBuilder/YarpCluster.cs:302

    [AspireExport("withClusterMetadata", MethodName = "withMetadata")]
    public static YarpCluster WithMetadata(this YarpCluster cluster, IReadOnlyDictionary<string, string> metadata)
    {
        cluster.Configure(c => c with { Metadata = metadata });
        return cluster;
    }

    // These mappings keep the existing public YARP-config overloads for .NET callers while exposing
    // ATS-friendly DTO shapes for polyglot callers. The raw YARP types include nested config objects,
    // Version values, and flags enums that do not round-trip cleanly through ATS as-is.
    private static ForwarderRequestConfig ToForwarderRequestConfig(YarpForwarderRequestConfig config)
    {
        Version? parsedVersion = null;

        if (!string.IsNullOrWhiteSpace(config.Version))
        {
            if (!Version.TryParse(config.Version, out var version))
            {
                throw new ArgumentException(
                    $"The value '{config.Version}' is not a valid HTTP version. Expected format is 'major.minor', for example '1.1' or '2.0'.",
                    nameof(config));
            }

            parsedVersion = version;
        }

        return new ForwarderRequestConfig
        {
            ActivityTimeout = config.ActivityTimeout,
            AllowResponseBuffering = config.AllowResponseBuffering,
            Version = parsedVersion,
            VersionPolicy = config.VersionPolicy,
        };
    }

    private static HttpClientConfig ToHttpClientConfig(YarpHttpClientConfig config)
    {

View on GitHub (pinned to 25830f84bd)