Server: response-metadata echo is only tested with x-custom-* names, so reserved names go unchecked

Open
#1,121 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
grpc, yaml
Domain
api, testing-qa

Research direction

Review duplicate_metadata.yaml and the server-mode cases under testsuites/*.yaml, then trace how responseHeaders and responseTrailers are interpreted. First resolve which behavior is conformant for reserved names; once decided, add cases for content-type, content-length, content-encoding, and trailers while preserving the multi-valued custom-header coverage. Done means the suite pins the chosen behavior without a harness change.

Written by the indexing model from the issue text.

Description

Summary

Server-mode tests only ever ask the server under test to echo two metadata names, x-custom-header and x-custom-trailer. Nothing exercises a name that collides with one the server sets itself, or a name that describes the transport rather than the payload. One such name makes a server emit a response a real client cannot read at all, and the suite does not notice.

The coverage

Collecting every name under responseHeaders or responseTrailers across all of testsuites/*.yaml:

  64  x-custom-trailer
  58  x-custom-header

That is the complete set. So no case covers either of:

  • a name the server also sets for itself — content-type being the obvious one;
  • a name scoped to the transport rather than the response payload — content-length, content-encoding, transfer-encoding, connection, date, grpc-encoding.

Both are ordinary in practice, because the natural way to write a gateway is to propagate an upstream error's metadata onto the response, and an upstream error's metadata contains exactly these names.

What that permits

Measured against connect-go v1.19.1 and grpc-go v1.81.1, driving a server that echoes an upstream error's header block onto its own error response, with a per-header bisect to isolate each name.

content-length is not survivable. A server that emits an echoed content-length: 4096 on a Connect error over HTTP/1.1 produces a response the HTTP/1 layer refuses to serialize — in our case the connection closed with zero bytes written. connect-go reports unexpected EOF with empty metadata. The handler's actual error code never reaches the client: a permission_denied arrived as unavailable, and every other code collapses the same way, because all the client ever observes is a transport failure.

The others are milder but real:

  • an echoed content-encoding: gzip makes connect-go attempt to gunzip a plain-JSON error body, discard it, and fall back to the HTTP status — losing the error code and message;
  • an echoed content-type is appended rather than replacing, so two content-type values reach the wire (both Go clients tolerate this, but it is malformed);
  • an echoed date displaces the one the server would otherwise set, so the response advertises a false generation time.

We shipped all of the above in connectrpc/connect-rust while passing server conformance 3600/0, Connect+TLS 2396/0, and all three client suites. duplicate_metadata.yaml was the closest existing case — it echoes multi-valued x-custom-header onto error responses across all four RPC kinds — but because the name is a custom one, it cannot catch any of this.

The question this is really asking

Unlike the sibling issues, this one is not "the implementations disagree, please pick". It is that the suite does not say what a conformant server should do when asked to echo a reserved name, and there are at least three defensible answers:

  1. Drop them. What we settled on: the response's own header wins, and transport-scoped names are not forwarded.
  2. Forward them verbatim. Defensible in principle, but content-length demonstrably yields an unreadable response, so this cannot be right for at least that name.
  3. Reject the RPC. Treat it as a handler error.

Whichever it is, pinning it would be worth doing, because the failure mode for getting it wrong is not a wrong error code — it is a response the peer cannot parse.

Suggested cases

Server-mode, expressible as test data with no harness change, since responseHeaders/responseTrailers already accept arbitrary names:

  1. responseHeaders containing content-type set to something other than what the protocol requires. Assert exactly one content-type reaches the wire, and that it is the protocol's.
  2. responseHeaders containing content-length with a value that does not match the body, on Connect over HTTP/1.1 specifically — the combination that produced the unserializable response.
  3. responseHeaders containing content-encoding: gzip on an uncompressed error body.
  4. A multi-valued custom name alongside the above, asserting both values still arrive — so that whatever filtering an implementation adds cannot over-reach. This is the regression guard for anyone implementing (1).
  5. The same set under responseTrailers, which is the same question one frame later.

Happy to send a PR once there is a decision on which of the three behaviours is conformant. If it helps, we can also contribute the interop harness we used for the bisect.

Dominant language
Go
Stars
96
Forks
22
Avg merge
1d 9h
Merged PRs (30d)
8

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from connectrpc/conformance

All issues in connectrpc/conformance

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.