Skip to content

Conversation

@Abishek-Newar
Copy link
Contributor

@Abishek-Newar Abishek-Newar commented Jan 23, 2026

Description

What problem is being solved?

The async_req parameter exists in the lower-level api_client.py to enable threading-based asynchronous requests using Python's ThreadPool. However, this parameter is not exposed through the public OpenFgaClient API because the options_to_kwargs function doesn't support it, making it inaccessible without using internal APIs.

How is it being solved?

Updated the options_to_kwargs function to pass through the async_req parameter from user options to the underlying API calls.

What changes are made to solve it?

  • Added async_req parameter support in openfga_sdk/sync/client/client.py (sync client)

After this change, users can use async_req like this:

result = client.list_stores(options={"async_req": True})

References

closes #194

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

Summary by CodeRabbit

  • New Features
    • Added support for asynchronous request handling in API client operations. Users can now pass async request preferences through configuration options to enable non-blocking API calls.

✏️ Tip: You can customize this high-level summary in your review settings.

@Abishek-Newar Abishek-Newar requested a review from a team as a code owner January 23, 2026 13:01
@dosubot
Copy link

dosubot bot commented Jan 23, 2026

Related Documentation

Checked 5 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Walkthrough

Adds support for passing the async_req parameter through the options mapping in both sync and async client implementations, allowing users to control async request behavior via the public API instead of internal APIs.

Changes

Cohort / File(s) Summary
Async Request Parameter Support
openfga_sdk/client/client.py, openfga_sdk/sync/client/client.py
Extends options_to_kwargs function to propagate async_req from options dictionary to kwargs, enabling async request signaling through public API calls. Identical change applied to both client implementations.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding support for the async_req parameter in the OpenFGA SDK.
Linked Issues check ✅ Passed The PR directly addresses all requirements from issue #194 by adding async_req parameter support to options_to_kwargs in both client implementations, enabling public API usage.
Out of Scope Changes check ✅ Passed All changes are directly related to exposing the async_req parameter through the public API, with no unrelated modifications to the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.16%. Comparing base (8cc5f26) to head (c6b496f).

Files with missing lines Patch % Lines
openfga_sdk/sync/client/client.py 50.00% 1 Missing ⚠️

❌ Your project status has failed because the head coverage (71.16%) 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   71.17%   71.16%   -0.01%     
==========================================
  Files         137      137              
  Lines       11100    11102       +2     
==========================================
+ Hits         7900     7901       +1     
- Misses       3200     3201       +1     

☔ 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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.

Copy link
Member

@SoulPancake SoulPancake left a 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
Copy link
Contributor Author

hi @SoulPancake , done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenFGA SDK doesn't seem to support async_req parameter

3 participants