Error 1041 occurs when a Cloudflare Transform Rule sets a header to a value that violates HTTP header specifications. Header values must conform to RFC 7230 — they cannot contain certain control characters, null bytes, or newlines. If a dynamic expression in a Transform Rule produces a value with illegal characters, Cloudflare returns 1041 instead of forwarding the malformed request to the origin.
The Transform Rule's expression generates a value containing control characters (like \r, \n, \0) that are not allowed in HTTP headers.
The rule tries to set a header value containing raw binary data or improperly encoded content that violates HTTP header formatting rules.
The expression evaluates to an empty string for a header that requires a non-empty value.
Review the Transform Rule's expression that generates the header value. Test what it evaluates to for the failing request.
If the header value comes from a dynamic source (like a request field), ensure it is sanitized to remove control characters and newlines before setting it as a header.
If the header value must contain special characters, URL-encode them first so the raw header value contains only valid characters.
A Transform Rule attempted to modify a request header that Cloudflare does not allow to be changed.
A Cloudflare Transform Rule or rewrite produced an invalid URI path.
A Cloudflare Transform Rule's expression could not be evaluated at runtime.