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
Copy Markdown

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

What type of PR is this?

  • 🍕 Feature
  • 🐛 Bug Fix
  • ⚙️ Config Change
  • 📝 CHANGELOG/README Update
  • 🎨 Linting
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🔁 Version Bump
  • ⏩ Revert

Description

🔁 Pull Request Template – BharatMLStack

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 grpc auto-lowercases keys, but Python 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 and comply with HTTP/2 header requirements.

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
  • Infra / build system change
  • Performance improvement
  • Refactor
  • Documentation
  • Other: ___________

📊 Benchmark / Metrics (if applicable)

N/A — constant value change only.

Key Requirement Doc

Pod Type:

  • H0
  • H1
  • H2

Why KRD is not required?
This is a one-line bug fix changing constant values from uppercase to lowercase. No architectural or design decisions involved.

Added Tests

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help

If yes, what is the strategy?

  • Manual
  • Unit Tests
  • API/Integration Tests

Root Cause

The Python SDK defined gRPC metadata headers with uppercase characters:

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

Python grpcio enforces RFC 7540 §8.1.2 strictly: HTTP/2 header names MUST be lowercase. Go grpc-go auto-lowercases metadata keys, so the Go SDK works. Python grpcio does not auto-lowercase and rejects them.

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.

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
Copy Markdown

readytoreview bot commented Mar 16, 2026

PR Validation Failed

PR description validation failed

Issues found:

  • no test selection made (Yes/No/Need Help!)
  • KRD link missing — provide a KRD document or check 'KRD is not required'
  • downstream systems impact not specified

Please fill out the form to fix this: Open Form

@turbo-turtle-github
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

@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
Copy Markdown

@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