Skip to content

fix(py-sdk): lowercase gRPC metadata headers for Python compatibility#359

Open
coding-shalabh wants to merge 1 commit intoMeesho:mainfrom
coding-shalabh:fix/py-sdk-grpc-header-case-165
Open

fix(py-sdk): lowercase gRPC metadata headers for Python compatibility#359
coding-shalabh wants to merge 1 commit intoMeesho:mainfrom
coding-shalabh:fix/py-sdk-grpc-header-case-165

Conversation

@coding-shalabh
Copy link

@coding-shalabh coding-shalabh commented Mar 16, 2026

🔁 Pull Request Template – BharatMLStack

Please fill out the following sections to help us review your changes efficiently.

Context:

Python gRPC clients fail with metadata was invalid error because header keys use uppercase characters, which violates HTTP/2 spec (RFC 7540 §8.1.2). Go's grpc auto-lowercases keys, but Python's grpcio rejects them.

Describe your changes:

Lowercased HEADER_CALLER_ID and HEADER_CALLER_TOKEN constants in py-sdk/grpc_feature_client/grpc_feature_client/client.py to match the Go server middleware expectations.

Testing:

Verified header values match Go server middleware constants in middleware.go. The fix is a constant value change — no logic changes.

Monitoring:

NA

Rollback plan

Revert the two constant values back to uppercase.

Checklist before requesting a review

  • I have reviewed my own changes?
  • Relevant or critical functionality is covered by tests?
  • Monitoring needs have been evaluated?
  • Any necessary documentation updates have been considered?

📂 Modules Affected

  • horizon (Real-time systems / networking)
  • online-feature-store (Feature serving infra)
  • trufflebox-ui (Admin panel / UI)
  • infra (Docker, CI/CD, GCP/AWS setup)
  • docs (Documentation updates)
  • Other: py-sdk

✅ Type of Change

  • Feature addition
  • Bug fix
  • Refactoring
  • Documentation
  • CI/CD or infra

Root Cause

The Python SDK defined headers as:

HEADER_CALLER_ID = "ONLINE-FEATURE-STORE-CALLER-ID"
HEADER_CALLER_TOKEN = "ONLINE-FEATURE-STORE-AUTH-TOKEN"

Python grpcio enforces RFC 7540 §8.1.2: header field names MUST be lowercase in HTTP/2. Go's grpc-go auto-lowercases metadata keys before sending, so the Go SDK works with uppercase constants. Python's grpcio does not — it raises:

Illegal header key
metadata was invalid: [('ONLINE-FEATURE-STORE-CALLER-ID', 'demo'), ...]

Fix

HEADER_CALLER_ID = "online-feature-store-caller-id"
HEADER_CALLER_TOKEN = "online-feature-store-auth-token"

These match the server-side constants in online-feature-store/internal/server/grpc/middleware.go:

callerIdHeader  = "online-feature-store-caller-id"
AuthTokenHeader = "online-feature-store-auth-token"

Fixes #165

…lity

Python grpcio rejects metadata keys containing uppercase characters
(HTTP/2 spec requires lowercase). The Go SDK works because Go's grpc
library auto-lowercases keys, but Python's grpcio does not.

Changed HEADER_CALLER_ID and HEADER_CALLER_TOKEN to lowercase to match
the Go server middleware expectations in middleware.go.

Fixes Meesho#165
@readytoreview
Copy link

readytoreview bot commented Mar 16, 2026

PR Validation Failed

PR description validation failed

Issues found:

  • no PR type selected
  • no test selection made (Yes/No/Need Help!)
  • downstream systems impact not specified

Please fill out the form to fix this: Open Form

@turbo-turtle-github
Copy link

turbo-turtle-github bot commented Mar 16, 2026

⚠️ CI Workflow did not complete successfully ⚠️

Links:
No additional links available.

Reason:

IsCICDConfigFilesPresentActivity: GET https://api.github.com/repos/Meesho/BharatMLStack/contents/?ref=fix%2Fpy-sdk-grpc-header-case-165: 404 No commit found for the ref fix/py-sdk-grpc-header-case-165 []

📘 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

coderabbitai bot commented Mar 16, 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: 9235751a-2955-461c-b1a4-c596592c065b

📥 Commits

Reviewing files that changed from the base of the PR and between aec2c74 and 00b5892.

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

Walkthrough

Updated gRPC authentication header constants from uppercase to lowercase format in the Python gRPC feature client. The changes modify two public header constants to use lowercase ASCII characters, aligning with HTTP/2 metadata requirements enforced by Python gRPC.

Changes

Cohort / File(s) Summary
gRPC Header Constants
py-sdk/grpc_feature_client/grpc_feature_client/client.py
Updated HEADER_CALLER_ID and HEADER_CALLER_TOKEN from uppercase to lowercase format to comply with Python gRPC HTTP/2 metadata validation requirements.

Assessment against linked issues

Objective Addressed Explanation
Resolve metadata validation errors in Python gRPC client [#165]
Update header keys to lowercase ASCII format [#165]

Suggested labels

coderabbit-bugfix

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Dynamic Configuration Validation ✅ Passed PR modified only Python SDK source code header constants, with no changes to application-dyn-*.yml configuration files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can scan for known vulnerabilities in your dependencies using OSV Scanner.

OSV Scanner will automatically detect and report security vulnerabilities in your project's dependencies. No additional configuration is required.

Copy link

@erk1nya erk1nya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

@erk1nya erk1nya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disregard previous approval - was automated test

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)

2 participants