Skip to content

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

Open
coding-shalabh wants to merge 1 commit into
Meesho: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 into
Meesho: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

🔁 Pull Request Template – BharatMLStack

Context:

Python gRPC clients fail with metadata was invalid when calling the online-feature-store service because the py-sdk defines metadata header keys in uppercase. HTTP/2 (RFC 7540 §8.1.2) requires header field names to be lowercase. The Go SDK works because grpc-go auto-lowercases metadata keys, but Python's grpcio enforces the spec strictly and rejects them.

Fixes #165.

Describe your changes:

Lowercased HEADER_CALLER_ID and HEADER_CALLER_TOKEN in py-sdk/grpc_feature_client/grpc_feature_client/client.py:

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

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

These now match the server-side constants in online-feature-store/internal/server/grpc/middleware.go, which the Go SDK was already sending in lowercase form (via grpc-go's auto-normalization).

Testing:

Manual:

  1. Built the py-sdk locally with the patch.
  2. Pointed it at a local online-feature-store instance.
  3. Confirmed that a GetFeatures call now succeeds; without the fix it returns metadata was invalid.

Existing automated tests: the constants are only consumed by the gRPC client header builder, which is exercised by every integration call. No new unit test added — verifying a 2-line constant change is best done at the wire/metadata level which the existing call paths cover.

Monitoring:

No new instrumentation required. Failures previously surfaced as metadata was invalid errors in gRPC client logs; after the fix those errors should no longer occur for Python callers. Existing gRPC server-side metrics for request count / error rate already cover regression detection.

Rollback plan

Single-file, two-line constant change. To revert: git revert <commit-sha> on the merge commit, or change the two constants back to uppercase. No data migrations, no schema changes, no config rollout. Rollback is instant on the next SDK release.

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 (Python gRPC client)

✅ 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, no perf impact.

…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

@coding-shalabh
Copy link
Copy Markdown
Author

Hi @erk1nya — sorry I missed the prior pings. I noticed the earlier "approval" was an automated test and you retracted it. Cleaning house here:

  • Rewrote the PR description to match the current pull_request_template.md (Testing / Monitoring / Rollback plan sections all filled, plus the standard checklists).
  • The PR Validation check appears to 404 because it's looking for the branch on Meesho/BharatMLStack instead of the fork coding-shalabh/BharatMLStack:
    GET /repos/Meesho/BharatMLStack/contents/?ref=fix/py-sdk-grpc-header-case-165 → 404 No commit found
    
    That's outside what I can fix from a fork — flagging in case it's a known bot issue with external contributors.

The actual change is a 2-line lowercase fix in py-sdk that unblocks Python gRPC clients (matches what the Go SDK already does via grpc-go's auto-normalization). Could someone do a fresh review when convenient? Thanks!

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