-
Notifications
You must be signed in to change notification settings - Fork 36
fix: OpenFGA SDK doesn't seem to support async_req parameter#253
fix: OpenFGA SDK doesn't seem to support async_req parameter #253Abishek-Newar wants to merge 7 commits into
Conversation
Related Documentation
Checked 5 published document(s) in 1 knowledge base(s). No updates required.
How did I do? Any feedback? Join Discord
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughAdds support for passing the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
Codecov Report
✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.03%. Comparing base (33a3168) to head (dd1f1fb).
❌ Your project status has failed because the head coverage (70.03%) 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 #253 +/- ## ========================================== + Coverage 69.84% 70.03% +0.19% ========================================== Files 140 140 Lines 10743 10747 +4 ========================================== + Hits 7503 7527 +24 + Misses 3240 3220 -20
☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@openfga_sdk/client/client.py`:
- Around line 123-124: Reject the async_req option in the async client path:
locate the code that checks options.get("async_req") and currently sets
kwargs["async_req"], and change it to raise a clear ValueError (or TypeError)
when options["async_req"] is not None, explaining that async_req is incompatible
with the async client (it triggers self.pool.apply_async and returns a
non-awaitable). Ensure the error message references async_req and the async
client so callers get an explicit, actionable failure instead of a silent
runtime error.
@SoulPancake
SoulPancake
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that it initially was added to the async client too
Please update the PR description - Remove the line about async client changes since you've already removed that code
You checked "I have added tests" but there are currently no test files are in the diff
Abishek-Newar
commented
Jan 23, 2026
hi @SoulPancake , done
@SoulPancake
SoulPancake
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Abishek-Newar
What I meant was, you need to add tests to assert this change
Not remove it from the description, I hope that helps 😅
@SoulPancake , Sorry, my bad 😅
I will make the changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR aims to expose the underlying OpenAPI-generated async_req threading option via the public client options, by passing it through options_to_kwargs to the generated API methods.
Changes:
- Add passthrough support for
options["async_req"]in the sync client’soptions_to_kwargs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Abishek-Newar
commented
Mar 23, 2026
Hii @SoulPancake , can you please check this
emilic
commented
Mar 24, 2026
Thanks for the contribution! However, I don't think we should add async_req support to the SDK.
The async_req parameter is a legacy pattern from OpenAPI Generator that uses threading (ThreadPool) under the hood. The Python SDK already provides a dedicated async client built on asyncio/aiohttp, which is the modern and recommended way to handle async operations in Python.
For example, you can use the async client today:
async with OpenFgaClient(configuration) as fga_client:
# Single async call
response = await fga_client.check(request)
# Concurrent calls
results = await asyncio.gather(
fga_client.check(request_1),
fga_client.check(request_2),
fga_client.check(request_3),
)
This gives you everything async_req would, with better performance characteristics and no threading overhead.
If there's a specific use case that the async client doesn't cover, we'd love to hear about it — happy to discuss further.
Uh oh!
There was an error while loading. Please reload this page.
Description
What problem is being solved?
The
async_reqparameter exists in the lower-levelapi_client.pyto enable threading-based asynchronous requests using Python'sThreadPool. However, this parameter is not exposed through the publicOpenFgaClientAPI because theoptions_to_kwargsfunction doesn't support it, making it inaccessible without using internal APIs.How is it being solved?
Updated the
options_to_kwargsfunction to pass through theasync_reqparameter from user options to the underlying API calls.What changes are made to solve it?
async_reqparameter support inopenfga_sdk/sync/client/client.py(sync client)After this change, users can use
async_reqlike this:References
closes #194
Review Checklist
mainSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.