Skip to content

fix(py-sdk): lowercase gRPC metadata header keys#368

Open
Mrsandeep27 wants to merge 1 commit into
Meesho:mainfrom
Mrsandeep27:fix/lowercase-grpc-metadata-headers
Open

fix(py-sdk): lowercase gRPC metadata header keys#368
Mrsandeep27 wants to merge 1 commit into
Meesho:mainfrom
Mrsandeep27:fix/lowercase-grpc-metadata-headers

Conversation

@Mrsandeep27
Copy link
Copy Markdown

@Mrsandeep27 Mrsandeep27 commented Apr 20, 2026

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

  • Python SDK builds a unary call with valid metadata (no more `Illegal header key`).
  • Server-side auth middleware still resolves the caller ID / token.
  • Existing Go SDK continues to work unchanged (headers are lowercased by grpc-go on send).

Summary by CodeRabbit

  • Bug Fixes
    • Updated gRPC authentication metadata headers to use lowercase naming conventions, ensuring proper communication and compatibility with gRPC services.

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
@turbo-turtle-github
Copy link
Copy Markdown

INT

⚠️ Production eligibility check workflow did not complete successfully ⚠️

Reason:

IsCICDConfigFilesPresentActivity: GET https://api.github.com/repos/Meesho/BharatMLStack/contents/?ref=fix%2Flowercase-grpc-metadata-headers: 404 No commit found for the ref fix/lowercase-grpc-metadata-headers []

📘 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.

@turbo-turtle-github
Copy link
Copy Markdown

INT

⚠️ CI Workflow did not complete successfully ⚠️

Links:
No additional links available.

Reason:

IsCICDConfigFilesPresentActivity: GET https://api.github.com/repos/Meesho/BharatMLStack/contents/?ref=fix%2Flowercase-grpc-metadata-headers: 404 No commit found for the ref fix/lowercase-grpc-metadata-headers []

📘 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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b0d786e6-7265-4513-af8b-5438655914dd

📥 Commits

Reviewing files that changed from the base of the PR and between 8ac9e31 and ec4d559.

📒 Files selected for processing (1)
  • py-sdk/grpc_feature_client/grpc_feature_client/client.py

Walkthrough

The PR updates gRPC metadata header keys in the Python client from uppercase to lowercase format. Constants HEADER_CALLER_ID and HEADER_CALLER_TOKEN are changed from "ONLINE-FEATURE-STORE-CALLER-ID" and "ONLINE-FEATURE-STORE-AUTH-TOKEN" to their lowercase equivalents.

Changes

Cohort / File(s) Summary
gRPC Metadata Header Keys
py-sdk/grpc_feature_client/grpc_feature_client/client.py
Updated internal constants used for gRPC metadata header keys from uppercase to lowercase format to comply with Python gRPC requirements.

Assessment against linked issues

Objective Addressed Explanation
Convert header keys to lowercase to fix gRPC Python compatibility error [#165] PR changes header keys to lowercase; however, the linked issue references HTTP/2 restrictions requiring "lowercase ASCII without hyphens," but the converted headers still contain hyphens. Clarification needed on whether hyphens in lowercase keys are acceptable.

Suggested labels

coderabbit-bugfix

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Dynamic Configuration Validation ✅ Passed No application-dyn-*.yml files were modified in this PR.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] GRPCFeatureClient sends invalid header keys that are incompatible with Python gRPC (metadata was invalid)

1 participant