dotnet/yarp · error · InvalidOperationException
The transform contains more parameters than expected: {strin
Error message
The transform contains more parameters than expected: {string.Join(';', rawTransform.Keys)} What it means
Thrown (or recorded) by TransformHelpers.CheckTooManyParameters / TryCheckTooManyParameters when a raw transform dictionary has more keys than the transform expects. Excess keys usually mean a typo'd extra field, a stray comma, or a misunderstanding of which keys belong to a transform. The check version throws InvalidOperationException; the Try version appends to context.Errors for validation.
Source
Thrown at src/ReverseProxy/Transforms/Builder/TransformHelpers.cs:23
using System.Collections.Generic;
namespace Yarp.ReverseProxy.Transforms.Builder;
public static class TransformHelpers
{
public static void TryCheckTooManyParameters(TransformRouteValidationContext context, IReadOnlyDictionary<string, string> rawTransform, int expected)
{
if (rawTransform.Count > expected)
{
context.Errors.Add(new InvalidOperationException("The transform contains more parameters than expected: " + string.Join(';', rawTransform.Keys)));
}
}
public static void CheckTooManyParameters(IReadOnlyDictionary<string, string> rawTransform, int expected)
{
if (rawTransform.Count > expected)
{
throw new InvalidOperationException("The transform contains more parameters than expected: " + string.Join(';', rawTransform.Keys));
}
}
internal static void RemoveAllXForwardedHeaders(TransformBuilderContext context, string prefix)
{
context.AddXForwardedFor(prefix + ForwardedTransformFactory.ForKey, ForwardedTransformActions.Remove);
context.AddXForwardedPrefix(prefix + ForwardedTransformFactory.PrefixKey, ForwardedTransformActions.Remove);
context.AddXForwardedHost(prefix + ForwardedTransformFactory.HostKey, ForwardedTransformActions.Remove);
context.AddXForwardedProto(prefix + ForwardedTransformFactory.ProtoKey, ForwardedTransformActions.Remove);
}
internal static void RemoveForwardedHeader(TransformBuilderContext context)
{
context.RequestTransforms.Add(RequestHeaderForwardedTransform.RemoveTransform);
}
}
View on GitHub (pinned to bd11867bee)
Solutions
- Compare the keys in the error to the transform's documented parameter set and remove the extra key.
- Split a multi-purpose transform object into separate transform entries.
- Run route config validation (TryCheckTooManyParameters path) during startup to surface these as config errors instead of runtime exceptions.
Example fix
// before
{ "PathRemovePrefix": "/api", "Set": "/new" }
// after
{ "PathRemovePrefix": "/api" } Defensive patterns
Strategy: validation
Validate before calling
TransformHelpers.CheckTooManyParameters(rawTransform, expected); // or for validation context: TransformHelpers.TryCheckTooManyParameters(context, rawTransform, expected);
Type guard
static bool HasExpectedKeys(IReadOnlyDictionary<string,string> raw, int expected) =>
raw.Count <= expected; Prevention
- Keep each transform entry to a single transform type's keys.
- Run TryCheckTooManyParameters during route validation to surface errors at startup.
- Review diffs of transform config carefully for stray keys.
When it happens
Trigger: A transform entry includes an unexpected extra key alongside the recognized ones, e.g. `PathRemovePrefix` with an additional `Set` key, or two transform types accidentally merged into one object.
Common situations: Merging transform config by hand and leaving a key from a sibling transform. Typo creating a phantom key. Old config retained a removed parameter after a YARP upgrade.
Related errors
- Unknown transform: {string.Join(';', rawTransform.Keys)}
- Unexpected value for Forwarded: {token}. Expected 'for', 'ho
- {string.Join(";", transformValues.Keys)}
- Unexpected parameters for RequestHeader: {string.Join(';', t
- {string.Join(";", transformValues.Keys)}
AI-assisted analysis of dotnet/yarp@bd11867bee (2026-08-13).
Data as JSON: /api/errors/3b9d2bc050d15455.
Report an issue: GitHub.