Skip to content

maxHeadersCount in BackendConfigPolicy not taken into account #14373

Description

@jgkirschbaum

kgateway version

v2.3.5

Kubernetes Version

v1.34.8

Describe the bug

The maxHeadersCount key in a BackendConfigPolicy is not taken into account, when doing a http request.

apiVersion: gateway.kgateway.dev/v1alpha1
kind: BackendConfigPolicy
metadata:
  name: mypolicy
  namespace: myapp
spec:
  targetRefs:
    - name: myservice
      group: ""
      kind: Service
  commonHttpProtocolOptions:
    maxHeadersCount: 200
  connectTimeout: 5s

The following curl request receives a HTTP/1.1 431 Request Header Fields Too Large.

#!/bin/bash

set -eEo pipefail

COUNT=150
HEADERS=()
for ((i=0; i<COUNT; i++)); do
    HEADERS+=(-H "x-h${i}: ${i}")
done

echo "Additional headers: $COUNT"
echo "Bytes in headers: $(printf "%s" "${HEADERS[@]}" | wc -c)"
curl -isSI --http1.1 https://gateway.example.com/path/ "${HEADERS[@]}"

Expected Behavior

The request is answered with a HTTP/1.1 200 OK.

Steps to reproduce the bug

See description.

Proxy pod logs

The following logentry is generated for every request.

{
    "authority": null,
    "backendCluster": null,
    "backendHost": null,
    "bytes_received": 0,
    "bytes_sent": 31,
    "method": null,
    "path": null,
    "protocol": "HTTP/1.1",
    "req_x_forwarded_for": null,
    "request_id": null,
    "resp_backend_service_time": null,
    "response_code": 431,
    "response_flags": "DPE",
    "start_time": "2026-07-09T08:51:01.005Z",
    "total_duration": 0,
    "user_agent": null
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    Status
    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions