{"record":{"id":"8a4c459b1d4c9d8a","repo":"dotnet/yarp","slug":"headername-cannot-be-null-or-empty-8a4c45","errorCode":null,"errorMessage":"'headerName' cannot be null or empty.","messagePattern":"'headerName' cannot be null or empty\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/ReverseProxy/Transforms/ResponseTrailerRemoveTransform.cs","lineNumber":20,"sourceCode":"// The .NET Foundation licenses this file to you under the MIT license.\n\nusing System;\nusing System.Diagnostics;\nusing System.Threading.Tasks;\nusing Microsoft.AspNetCore.Http.Features;\n\nnamespace Yarp.ReverseProxy.Transforms;\n\n/// <summary>\n/// Removes a response trailer.\n/// </summary>\npublic class ResponseTrailerRemoveTransform : ResponseTrailersTransform\n{\n    public ResponseTrailerRemoveTransform(string headerName, ResponseCondition condition)\n    {\n        if (string.IsNullOrEmpty(headerName))\n        {\n            throw new ArgumentException($\"'{nameof(headerName)}' cannot be null or empty.\", nameof(headerName));\n        }\n\n        HeaderName = headerName;\n        Condition = condition;\n    }\n\n    internal string HeaderName { get; }\n\n    internal ResponseCondition Condition { get; }\n\n    // Assumes the response status code has been set on the HttpContext already.\n    /// <inheritdoc/>\n    public override ValueTask ApplyAsync(ResponseTrailersTransformContext context)\n    {\n        ArgumentNullException.ThrowIfNull(context);\n\n        Debug.Assert(context.ProxyResponse is not null);\n","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/dotnet/yarp/blob/bd11867bee7df522e7fd3effb08a9c85fd616908/src/ReverseProxy/Transforms/ResponseTrailerRemoveTransform.cs#L2-L38","documentation":"ResponseTrailerRemoveTransform's constructor throws ArgumentException when headerName is null or empty. The transform removes a named response trailer (trailing headers in HTTP/2), so a concrete name is required. Like the response-header variant it takes a ResponseCondition.","triggerScenarios":"Constructing `new ResponseTrailerRemoveTransform(headerName, condition)` with a null/empty headerName. Via config when the 'ResponseTrailerRemove' value is empty, or programmatically.","commonSituations":"Config `{ \"ResponseTrailerRemove\": \"\" }`; a programmatic transform with an uninitialised name; a dynamic trailer-name list containing an empty entry.","solutions":["Supply a real trailer name, e.g. \"X-Grpc-Status\".","Populate the config ResponseTrailerRemove value.","Filter empty entries from dynamic lists before constructing."],"exampleFix":"// before\n{ \"ResponseTrailerRemove\": \"\" }\n// after\n{ \"ResponseTrailerRemove\": \"X-Grpc-Status\" }","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(headerName))\n    throw new InvalidOperationException(\"A trailer name is required to remove.\");\nvar t = new ResponseTrailerRemoveTransform(headerName, condition);","typeGuard":"static bool IsValidHeaderName(string? name)\n    => !string.IsNullOrWhiteSpace(name);","tryCatchPattern":null,"preventionTips":["Filter empty entries from dynamic trailer-name lists before constructing.","Validate config ResponseTrailerRemove values are non-empty.","Prefer context.AddResponseTrailerRemove from validated config."],"tags":["yarp","transforms","argument-validation","trailers","response"],"backgroundTag":null,"analyzedSha":"bd11867bee7df522e7fd3effb08a9c85fd616908","analyzedAt":"2026-08-13T21:29:49.359Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}