You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to set a metadata key/value pair for an http/2 header like so:
var meta = new grpc.Metadata();
meta.add(':authority', 'account');
This fails with the following error:
Error: Metadata key":authority" contains illegal characters
web_1 | at normalizeKey (/app/node_modules/grpc/src/node/src/metadata.js:67:11)
web_1 | at Metadata.add (/app/node_modules/grpc/src/node/src/metadata.js:108:9)
web_1 | at Promise (/app/src/functions/index.js:54:10)
web_1 | at Object.createUserSession (/app/src/functions/index.js:52:10)
web_1 | at createUserSession (/app/src/routes/index.js:8:23)
web_1 | at Promise.resolve.then (/app/src/lib/promisify-grpc.js:6:16)
web_1 | at process._tickDomainCallback (internal/process/next_tick.js:135:7)
web_1 | Processing [/auth.Authenticator/CreateUserSession]
The problem is that Metadata.add() does not allow a key value pair with a key that contains a colon. However, shouldn't this be allowed considering the HTTP/2 spec specifies that pseudo headers (such as :authority) are supposed to be implemented with a leading colon?
P.S. I did find this issue, which identifies the same problem, but does not actually discuss whether or not metadata keys SHOULD support a colon: grpc/grpc-go#613
I also just realized that gRPC metadata is not the same thing as HTTP/2 headers (and I'm guessing aren't implemented as such), in which case this issue is probably not relevant. Is there a way to modify the underlying HTTP/2 headers for a gRPC request?
You can't directly set the :authority header because gRPC internally handles HTTP2 protocol pseudo-headers. You can modify the authority for an entire client by setting the option "grpc.default_authority" at client construction, and I think you can set it for a single call by passing it in the host key in the options call argument.
gRPC metadata does in fact correspond directly to HTTP2 headers.
Hello,
I am trying to set a metadata key/value pair for an http/2 header like so:
This fails with the following error:
The problem is that Metadata.add() does not allow a key value pair with a key that contains a colon. However, shouldn't this be allowed considering the HTTP/2 spec specifies that pseudo headers (such as :authority) are supposed to be implemented with a leading colon?
Link to offending code:
https://github.com/grpc/grpc-node/blob/master/packages/grpc-js-core/src/metadata.ts
P.S. I did find this issue, which identifies the same problem, but does not actually discuss whether or not metadata keys SHOULD support a colon: grpc/grpc-go#613
P.P.S. Just to provide some context, I want to use the :authority header because Envoy proxy relies on this header to determine where a request should be forwarded to. Though this has little to do with gRPC, thought it might be useful to provide a legitimate use case. https://www.envoyproxy.io/docs/envoy/latest/intro/deployment_types/service_to_service.html#service-to-service-egress-listener
The text was updated successfully, but these errors were encountered: