[SDK] Add Changes to Clone Downstream and Upstream Header Contexts#2631
Conversation
📝 WalkthroughWalkthroughThe Go and Python policy SDKs add downstream request and upstream route/response snapshot types. These snapshots are exposed through request, response, and streaming context structures, with Python public exports updated and the legacy Go upstream field deprecated. ChangesGateway header context snapshots
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
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
cab5934 to
95e42ee
Compare
This comment was marked as outdated.
This comment was marked as outdated.
95e42ee to
3c9319e
Compare
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 @.github/workflows/sdk-ai-release.yml:
- Around line 4-6: Safely handle the manual version input in
.github/workflows/sdk-ai-release.yml lines 4-6,
.github/workflows/sdk-core-release.yml lines 4-6, and
.github/workflows/sdk-release.yml lines 4-6: pass inputs.version through an
environment variable rather than interpolating it into shell code, validate it
against strict semantic-version syntax before creating any tag, and use only the
validated value for subsequent release commands.
🪄 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: 398e2658-f176-4f62-b396-bb2b653a08af
📒 Files selected for processing (3)
.github/workflows/sdk-ai-release.yml.github/workflows/sdk-core-release.yml.github/workflows/sdk-release.yml
3c9319e to
d6ee199
Compare
Refactor context types to improve clarity and consistency in upstream/downstream handling
Refactor context types to enhance clarity and consistency in downstream and upstream request handling
d6ee199 to
acc2061
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.