Skip to content

Conversation

@rhamzeh
Copy link
Member

@rhamzeh rhamzeh commented Sep 12, 2025

Description

What problem is being solved?

How is it being solved?

What changes are made to solve it?

References

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 [Provide a link to any relevant PRs in the references section above]
  • 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

    • Expanded SDK surface with additional publicly available models and a dedicated API client.
  • Documentation

    • Clarified Batch Check behavior: parallel execution, up to 3 retries on 429/5xx, configurable max checks with automatic request splitting.
    • Clarified Read input: user must be a full object (type:id).
    • Added/reshuffled docs (e.g., UserTypeFilter, Usersets) and new examples, including OpenTelemetry and streamed listings.
    • Updated README accordingly.
  • Tests

    • Minor formatting, added resource cleanup, and adjusted one test from async to sync.
  • Chores

    • Added LICENSE and VERSION; initialized test packages.

@rhamzeh rhamzeh marked this pull request as ready for review September 12, 2025 19:50
@rhamzeh rhamzeh requested review from a team as code owners September 12, 2025 19:50
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 12, 2025

Walkthrough

Updates the generator manifest, reorganizes docs and examples, adds/clarifies API method docstrings, and adjusts tests (formatting, one async→sync change, added client cleanup). No functional SDK code changes; primarily documentation and manifest exposure of additional model modules and example scaffolding.

Changes

Cohort / File(s) Change summary
Generator manifest and exposure
\.openapi-generator/FILES
Refreshed file manifest: added LICENSE/README/VERSION, new docs and examples, exposed new model modules (e.g., condition, usersets, tuple variants), added openfga_sdk/api_client.py, and test package init files. Reordered/expanded public entries.
Docs and README
README.md, docs/OpenFgaApi.md
Clarified Batch Check behavior/limits and retry notes; added constraint for read tuple_key.user requiring full object. Wording and structure updates only.
API docstrings (async and sync)
openfga_sdk/api/open_fga_api.py, openfga_sdk/sync/open_fga_api.py
Augmented docstrings for batch_check and read methods: environment variable for max batch size, SDK auto-splitting, and read input constraint. No logic changes.
Tests (async/sync, formatting, cleanup)
test/oauth2_test.py, test/sync/oauth2_test.py
Reformatted function signatures across lines; converted one test from async to sync in sync suite; added rest_client.close() cleanup in one test. No core logic changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • release: v0.9.5 #200 — Touches the same OpenFGA API docstrings (read/batch_check) and updates the .openapi-generator/FILES manifest, indicating parallel documentation and manifest alignment.

Pre-merge checks (3 passed)

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "chore: sync sdk generator changes" accurately describes the primary intent of the changeset — synchronizing generator-produced SDK artifacts (manifest updates, added/updated models, API client entries, docs and examples) — and is concise and clear for repository history. It uses a standard "chore:" prefix and directly relates to the main changes described in the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/sync-sdk-generator-changes

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 Sep 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.70%. Comparing base (89a39d1) to head (7ce1792).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #221   +/-   ##
=======================================
  Coverage   70.70%   70.70%           
=======================================
  Files         134      134           
  Lines       10881    10881           
=======================================
  Hits         7693     7693           
  Misses       3188     3188           

☔ 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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (5)
openfga_sdk/sync/open_fga_api.py (1)

43-47: Context manager bug: exit signature is invalid (will raise TypeError).

__exit__ must accept (exc_type, exc_value, traceback). Current signature breaks with OpenFgaApi(...) as ...: usage.

-    def __exit__(self):
-        self.close()
+    def __exit__(self, exc_type, exc_value, traceback):
+        self.close()
+        # returning None propagates exceptions
test/sync/oauth2_test.py (1)

343-393: Test name/docs vs behavior mismatch (uses 429s but says “5xx”).

Either rename the test or include a 5xx in the sequence. Suggest exercising both retryable classes.

-    def test_get_authentication_retries_5xx_responses(self, mock_request):
+    def test_get_authentication_retries_retryable_responses(self, mock_request):
@@
-        """
-        Receiving a 5xx response from the server should be retried
-        """
+        """
+        Receiving retryable responses (429 and 5xx) should be retried.
+        """
@@
-        mock_request.side_effect = [
-            mock_response(error_response_body, 429),
-            mock_response(error_response_body, 429),
-            mock_response(error_response_body, 429),
-            mock_response(response_body, 200),
-        ]
+        mock_request.side_effect = [
+            mock_response(error_response_body, 429),
+            mock_response(error_response_body, 503),
+            mock_response(error_response_body, 429),
+            mock_response(response_body, 200),
+        ]
docs/OpenFgaApi.md (1)

1-1542: Fix broken Python examples (remove extra .api_instance) and correct 'conisistency' typo

  • Replace all example calls like api_instance.api_instance.<method>(...) with await api_instance.<method>(...) in docs/OpenFgaApi.md (occurrences at lines: 70, 154, 236, 319, 401, 484, 567, 650, 736, 820, 904, 988, 1073, 1161, 1248, 1332, 1417, 1501).
  • Fix the typo conisistencyconsistency in docs/OpenFgaApi.md (≈ lines 116, 529) and in generated SDK docstrings: openfga_sdk/sync/open_fga_api.py and openfga_sdk/api/open_fga_api.py (docstring occurrences around lines ~233, ~260, ~1067–1097).

If docs/SDK files are generated, update the generator/templates to prevent recurrence.

openfga_sdk/api/open_fga_api.py (2)

100-106: Docs/code kwarg mismatch: _retry_param (docs) vs _retry_params (accepted). Accept both to avoid FgaValidationException.

Right now, passing _retry_param (as documented) raises “unexpected keyword argument.” Either update docs everywhere to _retry_params or accept both and normalize.

         all_params.extend(
             [
                 "async_req",
                 "_return_http_data_only",
                 "_preload_content",
                 "_request_timeout",
                 "_request_auth",
                 "_content_type",
                 "_headers",
-                "_retry_params",
+                "_retry_param",
+                "_retry_params",
                 "_streaming",
             ]
         )
@@
-        del local_var_params["kwargs"]
+        del local_var_params["kwargs"]
+        # Back-compat: normalize singular '_retry_param' to '_retry_params'
+        if local_var_params.get("_retry_param") is not None and local_var_params.get("_retry_params") is None:
+            local_var_params["_retry_params"] = local_var_params["_retry_param"]

If you prefer doc-only changes, I can generate a follow-up patch to replace all _retry_param mentions with _retry_params across this file. Want that?

Also applies to: 122-126


235-235: Fix user-facing typos and minor grammar in docstrings

These appear multiple times and are visible to users.

  • “conisistency” → “consistency” (e.g., Lines 235, 1096)
  • “viceversa” → “vice versa” (Line 235 block)
  • “the the ListObjects API” → “the ListObjects API” (Lines 2489 and 2516 blocks)
  • “along side” → “alongside” (Lines 2316, 2350)
  • “an user” → “a user” (Line 2670 block)

I can submit a sweep commit if you want.

Also applies to: 1096-1096, 2489-2489, 2516-2516, 2316-2316, 2350-2350, 2670-2670

🧹 Nitpick comments (10)
README.md (1)

831-834: Clarify error semantics and result ordering for client_batch_check.

  • Make explicit that allowed: false due to an error is an indeterminate result and should be handled by inspecting error.
  • Note that responses may not preserve input order; pairing should rely on the echoed request.
-If you are using an OpenFGA version less than 1.8.0, you can use `client_batch_check`,
-which calls `check` in parallel. It will return `allowed: false` if it encounters an error, and will return the error in the body.
-If 429s or 5xxs are encountered, the underlying check will retry up to 3 times before giving up.
+If you are using an OpenFGA version less than 1.8.0, you can use `client_batch_check`,
+which calls `check` in parallel. On error, each item will include an `error` and set `allowed: false` (treat as indeterminate, not a definitive denial).
+Result ordering is not guaranteed; pair results using the echoed `request` field.
+If 429s or 5xxs are encountered, the underlying `check` will retry up to 3 times before giving up (see "Retries" below).
openfga_sdk/sync/open_fga_api.py (5)

52-52: Docstring: align type names and wording; keep NOTE concise.

  • Prefer model names used in docs: “BatchCheckSingleResult” instead of "BatchCheckItem response".
  • Keep “SDK can split requests” but avoid redundancy.
-returns a map containing `BatchCheckItem` response for each check it received.
+returns a map of `correlation_id` → `BatchCheckSingleResult` for each check.

101-104: Docstring parameter name mismatch: _retry_param vs _retry_params.

The implementation uses _retry_params; fix the docstring to match.

-        :param _retry_param: if specified, override the retry parameters specified in configuration
+        :param _retry_params: if specified, override the retry parameters specified in configuration

233-261: Typos in user-facing docstring.

  • “conisistency” → “consistency”
  • “viceversa” → “vice versa”
- higher conisistency
+ higher consistency
- and viceversa.
+ and vice versa.

260-289: Docstring parameter name mismatch in check_with_http_info.

Same _retry_param vs _retry_params inconsistency.

-        :param _retry_param: if specified, override the retry parameters specified in configuration
+        :param _retry_params: if specified, override the retry parameters specified in configuration

1067-1096: Typos in ListObjects docstrings.

  • “conisistency” → “consistency”
- higher conisistency
+ higher consistency
docs/OpenFgaApi.md (2)

32-32: Tighten NOTE and fix lint (MD038: spaces inside code spans).

  • Replace “BatchCheckItem” with “BatchCheckSingleResult”.
  • Remove any spaces inside backticked code spans.
  • Keep the NOTE concise.
- NOTE: The maximum number of checks that can be passed in the `BatchCheck` API is configurable via the [OPENFGA_MAX_CHECKS_PER_BATCH_CHECK](https://openfga.dev/docs/getting-started/setup-openfga/configuration#OPENFGA_MAX_CHECKS_PER_BATCH_CHECK) environment variable. If `BatchCheck` is called using the SDK, the SDK can split the batch check requests for you.
+ NOTE: The maximum number of checks in `BatchCheck` is configurable via [`OPENFGA_MAX_CHECKS_PER_BATCH_CHECK`](https://openfga.dev/docs/getting-started/setup-openfga/configuration#OPENFGA_MAX_CHECKS_PER_BATCH_CHECK). When called via the SDK, large batches may be auto-split.

Also update:

-returns a map containing `BatchCheckItem` response
+returns a map of `correlation_id` → `BatchCheckSingleResult`

782-783: Clarify bullet 3 and fix MD038.

  • Clarify that tuple_key.user must be fully qualified when tuple_key.object is type-only.
  • Ensure no spaces inside backticks.
-3. `tuple_key.user` is mandatory if tuple_key is specified in the case the `tuple_key.object` is a type only. If tuple_key.user is specified, it needs to be a full object (e.g., `type:user_id`).
+3. `tuple_key.user` is mandatory when `tuple_key.object` is type-only (e.g., `document:`) and must be fully qualified (e.g., `user:anne`).
openfga_sdk/api/open_fga_api.py (2)

54-54: Clarify BatchCheck splitting applies to the high-level Client, not this low-level API class

As written, this may mislead users into expecting OpenFgaApi to split batches automatically. Suggest narrowing the scope to the high-level client.

- NOTE: The maximum number of checks that can be passed in the `BatchCheck` API is configurable via the [OPENFGA_MAX_CHECKS_PER_BATCH_CHECK](https://openfga.dev/docs/getting-started/setup-openfga/configuration#OPENFGA_MAX_CHECKS_PER_BATCH_CHECK) environment variable. If `BatchCheck` is called using the SDK, the SDK can split the batch check requests for you.
+ NOTE: The maximum number of checks that can be passed in the `BatchCheck` API is configurable via the [OPENFGA_MAX_CHECKS_PER_BATCH_CHECK](https://openfga.dev/docs/getting-started/setup-openfga/configuration#OPENFGA_MAX_CHECKS_PER_BATCH_CHECK) environment variable. If you call `BatchCheck` via the high-level client (openfga_sdk.client.Client), the SDK may split batch check requests automatically. Direct calls via OpenFgaApi send the batch as-is.

81-81: Mirror clarification in with_http_info variant

Keep the scope clarification consistent here as well.

- NOTE: The maximum number of checks that can be passed in the `BatchCheck` API is configurable via the [OPENFGA_MAX_CHECKS_PER_BATCH_CHECK](https://openfga.dev/docs/getting-started/setup-openfga/configuration#OPENFGA_MAX_CHECKS_PER_BATCH_CHECK) environment variable. If `BatchCheck` is called using the SDK, the SDK can split the batch check requests for you.
+ NOTE: The maximum number of checks that can be passed in the `BatchCheck` API is configurable via the [OPENFGA_MAX_CHECKS_PER_BATCH_CHECK](https://openfga.dev/docs/getting-started/setup-openfga/configuration#OPENFGA_MAX_CHECKS_PER_BATCH_CHECK) environment variable. If you call `BatchCheck` via the high-level client (openfga_sdk.client.Client), the SDK may split batch check requests automatically. Direct calls via OpenFgaApi send the batch as-is.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89a39d1 and 7ce1792.

📒 Files selected for processing (7)
  • .openapi-generator/FILES (6 hunks)
  • README.md (1 hunks)
  • docs/OpenFgaApi.md (2 hunks)
  • openfga_sdk/api/open_fga_api.py (4 hunks)
  • openfga_sdk/sync/open_fga_api.py (4 hunks)
  • test/oauth2_test.py (2 hunks)
  • test/sync/oauth2_test.py (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
test/oauth2_test.py (1)
test/sync/oauth2_test.py (2)
  • test_get_authentication_obtain_client_credentials_with_scopes_list (108-164)
  • test_get_authentication_obtain_client_credentials_with_scopes_string (167-223)
test/sync/oauth2_test.py (4)
openfga_sdk/sync/open_fga_api.py (1)
  • close (46-47)
openfga_sdk/sync/api_client.py (1)
  • close (121-128)
openfga_sdk/sync/client/client.py (1)
  • close (178-179)
openfga_sdk/sync/rest.py (1)
  • close (218-222)
🪛 markdownlint-cli2 (0.17.2)
docs/OpenFgaApi.md

32-32: Spaces inside code span elements

(MD038, no-space-in-code)


32-32: Spaces inside code span elements

(MD038, no-space-in-code)


782-782: Spaces inside code span elements

(MD038, no-space-in-code)


782-782: Spaces inside code span elements

(MD038, no-space-in-code)


782-782: Spaces inside code span elements

(MD038, no-space-in-code)


782-782: Spaces inside code span elements

(MD038, no-space-in-code)


782-782: Spaces inside code span elements

(MD038, no-space-in-code)


782-782: Spaces inside code span elements

(MD038, no-space-in-code)

🔇 Additional comments (6)
test/sync/oauth2_test.py (2)

108-110: LGTM: multiline signature improves readability.

No behavior change; keeping it.


166-169: LGTM: multiline signature + explicit resource cleanup.

Adding rest_client.close() avoids leaked connections.

Also applies to: 223-223

openfga_sdk/api/open_fga_api.py (2)

1602-1602: LGTM: clearer Read input constraints

The “tuple_key.user must be a full object when object is type-only” addition aligns with server behavior and prevents ambiguous inputs.


1629-1629: LGTM: same clarification for read_with_http_info

Consistent, accurate, and helpful.

test/oauth2_test.py (2)

499-501: LGTM: multiline signature improves readability

No behavioral change; consistent with surrounding style.


558-560: LGTM: same here

Matches formatting of other tests; no logic impact.

@rhamzeh rhamzeh added this pull request to the merge queue Sep 12, 2025
Merged via the queue into main with commit 94c4d36 Sep 12, 2025
36 of 37 checks passed
@rhamzeh rhamzeh deleted the chore/sync-sdk-generator-changes branch September 12, 2025 22:50
@coderabbitai coderabbitai bot mentioned this pull request Oct 23, 2025
4 tasks
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.

3 participants