Skip to content

Commit b5ed306

Browse files
committed
fix: align request ID to standard x-request-id with backward compatibility
this adds x-request-id support in both headers and trailers: - RequestIDHeader: new header constant for HTTP/1.1 clients that can't easily read trailers through the gateway - RequestID: stays as a trailer to maintain gRPC retry policy compatibility (see cefe49ab for why trailers matter) - RequestIDLegacy: keeps the old io.spicedb.respmeta.requestid key around so existing clients don't break during transition
1 parent 5fcedec commit b5ed306

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pkg/responsemeta/responsemeta.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ import (
1313
type ResponseMetadataHeaderKey string
1414

1515
const (
16-
// RequestID is the key in the response header metadata for the request's tracking ID, if any.
17-
RequestID ResponseMetadataHeaderKey = "x-request-id"
16+
// RequestIDHeader is the key in the response header metadata for the request's tracking ID.
17+
// Provided for HTTP gateway compatibility where trailers are not easily accessible.
18+
RequestIDHeader ResponseMetadataHeaderKey = "x-request-id"
1819

1920
// ServerVersion is the key in the response header metadata holding the version of the server
2021
// handling the API request, if requested via a request header.
@@ -25,6 +26,14 @@ const (
2526
type ResponseMetadataTrailerKey string
2627

2728
const (
29+
// RequestID is the key in the response trailer metadata for the request's tracking ID.
30+
// Uses trailer to maintain gRPC retry policy compatibility (see gRPC proposal A6).
31+
RequestID ResponseMetadataTrailerKey = "x-request-id"
32+
33+
// RequestIDLegacy is the legacy key in the response trailer metadata for backward compatibility.
34+
// Kept to avoid breaking existing clients during transition period.
35+
RequestIDLegacy ResponseMetadataTrailerKey = "io.spicedb.respmeta.requestid"
36+
2837
// DispatchedOperationsCount is the key in the response trailer metadata for
2938
// the number of dispatched operations that were needed to perform the overall
3039
// API call.

0 commit comments

Comments
 (0)