[SDK] Add Changes to Clone Downstream and Upstream Header Contexts#2631
[SDK] Add Changes to Clone Downstream and Upstream Header Contexts#2631SavinduDimal wants to merge 2 commits into
Conversation
|
Warning Review limit reached
Next review available in: 46 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe policy SDK context APIs now define downstream and upstream header snapshot types and expose them through request, response, and streaming context dataclasses and structs in Python and Go. ChangesGateway header context snapshots
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@sdk-python/src/apip_sdk_core/policy/v1alpha2/types.py`:
- Around line 132-153: Make the headers fields in DownstreamContext and
UpstreamContext nullable to match the documented unavailable-state behavior and
the Go SDK contract. Update both annotations and defaults so instances can
represent None rather than always constructing Headers(), while preserving the
existing context classes and docstrings.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8e28d677-516c-4bc1-822e-7da2b72469d3
📒 Files selected for processing (3)
sdk-python/src/apip_sdk_core/policy/v1alpha2/__init__.pysdk-python/src/apip_sdk_core/policy/v1alpha2/types.pysdk/core/policy/v1alpha2/context.go
1f365f7 to
cab5934
Compare
Purpose
Description
This pull request introduces support for immutable snapshots of original client request and upstream response headers in both the Go and Python SDKs. These snapshots, represented by new
DownstreamContextandUpstreamContexttypes, are now available in all policy context objects, allowing policies to access unchanged headers.New Context Types and Header Snapshots:
DownstreamContextandUpstreamContexttypes to both Go (context.go) and Python (types.py) SDKs, each holding immutable copies of original client request and upstream response headers, respectively. [1] [2]RequestHeaderContext,ResponseHeaderContext,RequestStreamContext, etc.) to include optionaldownstreamandupstreamfields referencing these new context types. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]Python SDK Integration:
DownstreamContextandUpstreamContextin the Python SDK’s__init__.pyand__all__to ensure they are exported and available for import. [1] [2] [3]Backward Compatibility:
None(Python) ornil(Go) on older gateways, and policies should fall back to legacy header validation if unavailable. [1] [2]These changes improve policy reliability by allowing access to original, unmodified headers, while maintaining backward compatibility with older gateway versions.