fix(py-sdk): lowercase gRPC metadata header keys#368
Conversation
grpcio's metadata validator enforces HTTP/2's rule that metadata keys must be ASCII-lowercase; uppercase keys are rejected client-side with `validate_metadata: INTERNAL: Illegal header key`, so calls never reach the server. - Rename HEADER_CALLER_ID to "online-feature-store-caller-id" - Rename HEADER_CALLER_TOKEN to "online-feature-store-auth-token" Server compatibility: the Go gRPC server reads metadata via `metadata.FromIncomingContext` + `md.Get(key)`, which is case-insensitive, so incoming lowercase keys match the existing Go SDK constants (which are also normalized to lowercase by grpc-go on the wire). Fixes Meesho#165
INTReason: 📘 Please check the Turbo Turtle FAQs for more details. 👉 If the reason is not self-explanatory or not covered in the FAQ, please reach out to @devops-oncall in the #devops-tech channel. |
INTLinks: Reason: 📘 Please check the Turbo Turtle FAQs for more details. 👉 If the reason is not self-explanatory or not covered in the FAQ, please reach out to @devops-oncall in the #devops-tech channel. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe PR updates gRPC metadata header keys in the Python client from uppercase to lowercase format. Constants Changes
Assessment against linked issues
Suggested labels
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fixes #165 — `GRPCFeatureClient` cannot send a single request from Python because grpcio rejects the uppercase metadata keys at client-side validation.
Problem
`py-sdk/grpc_feature_client/grpc_feature_client/client.py` declares:
```python
HEADER_CALLER_ID = "ONLINE-FEATURE-STORE-CALLER-ID"
HEADER_CALLER_TOKEN = "ONLINE-FEATURE-STORE-AUTH-TOKEN"
```
When these are passed to `.with_call(metadata=...)`, grpcio's `validate_metadata` checks each key against HTTP/2's grammar — ASCII-lowercase only — and fails with:
```
INTERNAL: Illegal header key
```
The call never leaves the Python process.
Fix
Rename both constants to lowercase:
```python
HEADER_CALLER_ID = "online-feature-store-caller-id"
HEADER_CALLER_TOKEN = "online-feature-store-auth-token"
```
Server compatibility
The server reads these via `metadata.FromIncomingContext(ctx)` + `md.Get(key)` (go-sdk/pkg/api/request_context.go:42-117). `metadata.MD.Get` is case-insensitive (grpc-go lowercases on lookup), so the server accepts both cases. The existing Go SDK (`go-sdk/pkg/onfs/client.go:18-19`) still declares uppercase constants — grpc-go silently normalizes them to lowercase on the wire, so there's no wire-level divergence between the two clients.
No changes needed on the Go side. The Go constants can be lowercased in a separate cleanup PR if you want consistency, but it isn't required for this fix.
Test plan
Summary by CodeRabbit