-
Notifications
You must be signed in to change notification settings - Fork 28
fix: custom header precedence #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughUpdates README branding from Twitter to X. Adjusts header precedence in API clients so per-request headers override defaults. Modifies client header-setting logic to only set when missing (None). Adds unit tests covering per-request/default header merge and override behaviors across async/sync clients and API calls. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User as Caller
participant Client as OpenFgaClient
participant Api as OpenFgaApi
participant Http as RESTClientObject
rect rgba(200,220,255,0.25)
note right of Client: Prepare request
User->>Client: call (e.g., check) with params + optional _headers
Client->>Client: set_heading_if_not_set(req.headers, key, value)<br/>Only set if existing is None
end
rect rgba(200,255,200,0.25)
note right of Api: Merge headers
Client->>Api: invoke API method with header_params
Api->>Api: header_params = {**default_headers,<br/> **(header_params or {})}
Api->>Api: Inject Cookie if configured
end
Api->>Http: request(method, url, headers=merged)
Http-->>Api: response
Api-->>Client: result
Client-->>User: result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
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 |
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (70.73%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #230 +/- ##
==========================================
- Coverage 70.73% 70.73% -0.01%
==========================================
Files 134 134
Lines 10884 10882 -2
==========================================
- Hits 7699 7697 -2
Misses 3185 3185 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
03a1a5b
to
3e8be76
Compare
…nfga/python-sdk into fix/custom-header-precedence
Note: the failing CodeQL status check is unrelated to this PR |
@coderabbitai review |
✅ Actions performedReview triggered.
|
Fixed the CodeQL issue - the reason was we had both custom and default setups. Disabled the default one |
This PR addresses a bug in which, when calling a Client API method with custom headers, those headers may not be sent as expected. An issue related to the way header merging was occurring could result in custom headers being dropped.
Before:
After:
References
Builds from → openfga/sdk-generator#627
Review Checklist
main
Summary by CodeRabbit
Documentation
Bug Fixes
Tests