Skip to content

Conversation

@evansims
Copy link
Contributor

@evansims evansims commented Jul 9, 2025

0.9.5 (2025-07-09)


Generated from → openfga/sdk-generator#570

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue to ensure the response body is properly read and available for error handling in async API calls.
  • Documentation

    • Clarified that the order of results from the batch check API is not guaranteed; users should use the correlation ID to match responses.
    • Improved and reformatted documentation for the Read API endpoint.
  • Chores

    • Updated SDK version to 0.9.5 throughout the project.
    • Updated dependency requirements and user agent strings to reflect the new version.
    • Reorganized and cleaned up file listings and manifest order.
  • Tests

    • Added a test to verify correct handling of response bodies in async error scenarios.
    • Updated tests to check for the new user agent string.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 9, 2025

Walkthrough

This update increments the SDK version from 0.9.4 to 0.9.5 across all relevant files and documentation. It includes a bug fix ensuring that the response body from aiohttp.ClientResponse is read and attached before error handling. Documentation, changelog, and test cases are updated to reflect the new version and clarify batch check API behavior.

Changes

Files/Paths Change Summary
.openapi-generator/FILES Reordered and regrouped manifest entries; no content changes.
CHANGELOG.md, VERSION.txt, setup.py, openfga_sdk/init.py Bumped version from 0.9.4 to 0.9.5 in changelog, version file, setup, and SDK.
README.md, docs/OpenFgaApi.md Clarified batch check result ordering and reformatted Read API documentation.
openfga_sdk/api/open_fga_api.py, openfga_sdk/sync/open_fga_api.py Updated docstrings for Read API methods for clarity; no logic changes.
openfga_sdk/api_client.py, openfga_sdk/sync/api_client.py Updated DEFAULT_USER_AGENT version string to 0.9.5.
openfga_sdk/oauth2.py, openfga_sdk/sync/oauth2.py Updated "User-Agent" header version string to 0.9.5 in OAuth2 token requests.
openfga_sdk/configuration.py Updated SDK version string in debug report to 0.9.5.
openfga_sdk/rest.py Bug fix: Ensure aiohttp.ClientResponse body is read and attached as data before error handling.
example/example1/requirements.txt, example/example1/setup.py Updated minimum SDK dependency to >= 0.9.5.
test/api/open_fga_api_test.py, test/sync/open_fga_api_test.py, test/oauth2_test.py, Updated "User-Agent" header version in test assertions to 0.9.5.
test/sync/oauth2_test.py Updated "User-Agent" header version in test assertion to 0.9.5.
test/rest_test.py Added async test verifying handle_response_exception reads and attaches response data for error handling.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant RESTClientObject
    participant aiohttp.ClientResponse

    Client->>RESTClientObject: handle_response_exception(response)
    alt response is aiohttp.ClientResponse and lacks data
        RESTClientObject->>aiohttp.ClientResponse: await read()
        aiohttp.ClientResponse-->>RESTClientObject: body bytes
        RESTClientObject->>aiohttp.ClientResponse: set data attribute
    end
    RESTClientObject->>Client: Raise appropriate exception with response data
Loading

Possibly related PRs

✨ 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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.68%. Comparing base (82fb7d1) to head (bdf25b3).

❌ Your project status has failed because the head coverage (70.68%) 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     #200   +/-   ##
=======================================
  Coverage   70.67%   70.68%           
=======================================
  Files         134      134           
  Lines       10870    10870           
=======================================
+ Hits         7682     7683    +1     
+ Misses       3188     3187    -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.

@evansims evansims marked this pull request as ready for review July 9, 2025 19:14
@evansims evansims requested review from a team as code owners July 9, 2025 19:14
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: 0

🔭 Outside diff range comments (1)
openfga_sdk/sync/oauth2.py (1)

82-87: Hard-coding the version string violates DRY

"openfga-sdk (python) 0.9.5" is now duplicated across async & sync clients and a few other modules. Every release requires manual search-and-replace, which is error-prone.

Consider deriving it once, e.g.:

from openfga_sdk import __version__

USER_AGENT = f"openfga-sdk (python) {__version__}"
...
headers = urllib3.response.HTTPHeaderDict(
    {
        "Accept": "application/json",
        "Content-Type": "application/x-www-form-urlencoded",
        "User-Agent": USER_AGENT,
    }
)

Then reuse USER_AGENT everywhere.

♻️ Duplicate comments (2)
openfga_sdk/oauth2.py (1)

82-87: Duplicate hard-coded User-Agent (see sync variant)
Same DRY concern as in sync/oauth2.py. Extract a single constant based on __version__.

test/sync/open_fga_api_test.py (1)

1894-1901: Same brittle User-Agent literal as above

Replicate the fix suggested for the previous block to avoid future maintenance churn.

🧹 Nitpick comments (16)
setup.py (1)

20-22: Avoid hard-coding the version string in multiple files

VERSION here now duplicates the constant in openfga_sdk/__init__.py and appears again in several generated files/tests. This scattering makes future bumps error-prone (one file inevitably drifts). Consider deriving the value from a single source, e.g.

from importlib.metadata import version as _pkg_ver
VERSION = _pkg_ver("openfga-sdk")

or by importing a lightweight version.py module generated once by the build script.
This keeps every location in sync and eliminates manual edits for each release.

example/example1/setup.py (1)

18-18: Specify an upper bound on the dependency range

"openfga-sdk >= 0.9.5" leaves the example project open to unexpected breaking changes from future major releases. Standard practice is to cap at the next incompatible major, e.g.

-REQUIRES = ["openfga-sdk >= 0.9.5"]
+REQUIRES = ["openfga-sdk >= 0.9.5, <1.0.0"]

(Adjust the upper bound to match semantic-versioning guarantees you intend to provide.)

openfga_sdk/configuration.py (1)

537-542: Remove duplicated literal version – fetch it programmatically

"SDK Package Version: 0.9.5" will diverge next time the version is bumped unless every file is edited again. Fetching the installed package version at runtime avoids this:

-import sys
+import sys
+from importlib.metadata import version as _pkg_ver
@@
-            "SDK Package Version: 0.9.5"
+            f"SDK Package Version: {_pkg_ver('openfga-sdk')}"

No circular import occurs because importlib.metadata reads distribution metadata without importing the openfga_sdk package itself.

test/sync/oauth2_test.py (1)

83-88: Derive User-Agent expectation from __version__

Hard-coding "openfga-sdk (python) 0.9.5" couples every test to the release process. Import the constant to keep tests evergreen:

-from openfga_sdk.configuration import Configuration
+from openfga_sdk import __version__ as SDK_VERSION
+from openfga_sdk.configuration import Configuration
@@
-                "User-Agent": "openfga-sdk (python) 0.9.5",
+                "User-Agent": f"openfga-sdk (python) {SDK_VERSION}",

This change removes the need to edit tests on every version bump.

README.md (1)

727-728: Clarify how to pair results with requests a bit further

Good call-out on the ordering guarantee. Consider adding a short example showing how correlation_id can be used to build a dict of {correlation_id: result} so that readers have a concrete pointer.
Something as small as:

results_by_id = {r["correlation_id"]: r for r in response.result}

would make the hint actionable.

openfga_sdk/api_client.py (1)

42-42: Avoid hard-coding the SDK version in the user-agent

Every bump currently requires touching this file (and its sync twin). Feed the value from the single source of truth (openfga_sdk.__version__) instead:

-import openfga_sdk.models
+import openfga_sdk
+import openfga_sdk.models
...
-DEFAULT_USER_AGENT = "openfga-sdk python/0.9.5"
+DEFAULT_USER_AGENT = f"openfga-sdk python/{openfga_sdk.__version__}"

Reduces drift risk and keeps the async/sync clients in sync automatically.

CHANGELOG.md (1)

3-7: Tag names inconsistent with previous releases

Prior entries use the v prefix (v0.9.4, v0.9.3, …) while the new links point to plain 0.9.5. Consider keeping the prefix for consistency and to avoid broken anchors in GitHub-generated release pages.

-### [0.9.5](https://github.com/openfga/python-sdk/compare/v0.9.4...0.9.5) (2025-07-09)
+### [v0.9.5](https://github.com/openfga/python-sdk/compare/v0.9.4...v0.9.5) (2025-07-09)
test/oauth2_test.py (1)

87-88: Derive expected User-Agent from the library version

These assertions repeat a literal "openfga-sdk (python) 0.9.5". If the version changes again the tests will fail for an unrelated reason.

-from urllib3 import response
+import openfga_sdk
+from urllib3 import response
...
-"User-Agent": "openfga-sdk (python) 0.9.5",
+"User-Agent": f"openfga-sdk (python) {openfga_sdk.__version__}",

This keeps the tests green when the version is bumped automatically by the generator. Apply to all occurrences.

Also applies to: 313-315, 368-370, 423-425, 478-480

openfga_sdk/sync/api_client.py (1)

41-41: Avoid hard-coding versioned User-Agent; source it from a single authority

The User-Agent string is now hard-coded with 0.9.5. Each release requires editing multiple files; one miss silently ships an inconsistent UA. Prefer building this from an authoritative value (e.g. openfga_sdk.__version__) and a format helper so every place automatically stays in sync.

-from openfga_sdk import __version__  # add near other imports
-
-DEFAULT_USER_AGENT = "openfga-sdk python/0.9.5"
+from openfga_sdk import __version__  # top-level import
+
+DEFAULT_USER_AGENT = f"openfga-sdk python/{__version__}"

This eliminates duplication across api_client.py, oauth2.py, tests, etc.

test/sync/open_fga_api_test.py (1)

1840-1847: Make UA expectation resilient to future version bumps

"User-Agent": "openfga-sdk python/0.9.5" will break on every release. Pull the value from the code under test:

-                    "User-Agent": "openfga-sdk python/0.9.5",
+                    "User-Agent": openfga_sdk.sync.api_client.DEFAULT_USER_AGENT,

(or import __version__ and format on-the-fly).
This keeps tests green when the version is bumped without touching test fixtures.

test/api/open_fga_api_test.py (2)

1781-1787: Avoid hard-coding SDK version in expected headers

Hard-coding "openfga-sdk python/0.9.5" will break the test on every version bump. Prefer deriving the value from the runtime package to keep the test future-proof.

-                    "User-Agent": "openfga-sdk python/0.9.5",
+                    "User-Agent": f"openfga-sdk python/{openfga_sdk.__version__}",

Repeat the same change wherever the header string is asserted in this file.


1835-1841: Duplicate hard-coded version string

Same issue as above—replace the literal 0.9.5 with openfga_sdk.__version__ to avoid perpetual test churn.

-                    "User-Agent": "openfga-sdk python/0.9.5",
+                    "User-Agent": f"openfga-sdk python/{openfga_sdk.__version__}",
openfga_sdk/sync/open_fga_api.py (2)

1600-1600: Docstring collapsed into a single ~2 K-char line – please keep paragraph breaks

The previous multi-line formatting was far more readable and diff-friendly.
Collapsing everything into one monster line makes maintenance (and future reviews) painful and will trip most linters for max-line-length.

Consider reverting to paragraph-based formatting or at least wrapping at ≈100 chars:

-        The Read API will return the tuples for a certain store that match a query filter specified in the body of the request.  The API doesn't guarantee order by any field.  It is different from the `/stores/{store_id}/expand` API ...
+        The Read API will return the tuples for a certain store that match a query
+        filter specified in the body of the request.
+
+        The API doesn't guarantee order by any field.  It differs from
+        `/stores/{store_id}/expand` because it only returns relationship tuples
+        that are *stored* and satisfy the query.
+
+        In the body:
+        1. `tuple_key` is optional. If not specified, all tuples are returned.
+        2. `tuple_key.object` is mandatory when `tuple_key` is present.
+        3. `tuple_key.user` is mandatory when `tuple_key.object` is type-only.

1627-1627: Same issue here – long-line docstring in read_with_http_info

Duplicating the giant one-liner in the _with_http_info variant compounds the readability issue. Apply the same paragraph re-flow as suggested above.

openfga_sdk/api/open_fga_api.py (2)

1602-1602: Wrap the monster docstring line for readability & tooling compat

The new sentence is ~1 600 chars long. Sphinx, IDE hovers, and plain pydoc all choke on such unwrapped text, making the docs hard to read and diff.
Break it into short paragraphs and use a bulleted list for points 1-3.

-        The Read API will return the tuples for a certain store that match a query filter specified in the body of the request.  The API doesn't guarantee order by any field.  It is different ...
+        The Read API returns all tuples that match the supplied filter.
+
+        • No ordering of results is guaranteed.  
+        • Unlike `/expand`, only stored relationship tuples are returned.  
+
+        Body rules  
+            1. `tuple_key` is **optional**; when omitted, all tuples are returned.  
+            2. If `tuple_key` is present, `tuple_key.object` is **required** and can
+               be either a fully-qualified object (`type:id`) or a type prefix (`type:`).  
+            3. When a type prefix is used, `tuple_key.user` becomes **required**.  
+
+        ## Examples
+        ...

Keeps the same content, but is friendlier to humans and doc generators.
No functional impact; purely a doc-nit.


1629-1629: Duplicate long-line issue in read_with_http_info docstring

Same extremely long line appears here. Apply the same wrapping as suggested
for read to avoid repeated lint / doc-build warnings and improve
maintainability.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82fb7d1 and bdf25b3.

📒 Files selected for processing (22)
  • .openapi-generator/FILES (8 hunks)
  • CHANGELOG.md (1 hunks)
  • README.md (1 hunks)
  • VERSION.txt (1 hunks)
  • docs/OpenFgaApi.md (1 hunks)
  • example/example1/requirements.txt (1 hunks)
  • example/example1/setup.py (1 hunks)
  • openfga_sdk/__init__.py (1 hunks)
  • openfga_sdk/api/open_fga_api.py (2 hunks)
  • openfga_sdk/api_client.py (1 hunks)
  • openfga_sdk/configuration.py (1 hunks)
  • openfga_sdk/oauth2.py (1 hunks)
  • openfga_sdk/rest.py (1 hunks)
  • openfga_sdk/sync/api_client.py (1 hunks)
  • openfga_sdk/sync/oauth2.py (1 hunks)
  • openfga_sdk/sync/open_fga_api.py (2 hunks)
  • setup.py (1 hunks)
  • test/api/open_fga_api_test.py (2 hunks)
  • test/oauth2_test.py (5 hunks)
  • test/rest_test.py (2 hunks)
  • test/sync/oauth2_test.py (1 hunks)
  • test/sync/open_fga_api_test.py (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
test/rest_test.py (2)
openfga_sdk/rest.py (6)
  • RESTClientObject (140-473)
  • status (96-100)
  • status (103-107)
  • handle_response_exception (263-301)
  • data (82-86)
  • data (89-93)
openfga_sdk/exceptions.py (1)
  • ValidationException (185-187)
🪛 LanguageTool
docs/OpenFgaApi.md

[style] ~782-~782: Consider using “who” when you are referring to people instead of objects.
Context: ...ation and object To query for all users that have reader relationship with `docume...

(THAT_WHO)


[style] ~782-~782: Consider using “who” when you are referring to people instead of objects.
Context: ...ticular document To query for all users that have any relationship with `document:20...

(THAT_WHO)

🪛 markdownlint-cli2 (0.17.2)
docs/OpenFgaApi.md

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 (8)
.openapi-generator/FILES (1)

4-4: Manifest re-ordering only – no code concerns

All touched lines are list re-ordering in a generator manifest. Nothing to review from a runtime or tooling standpoint.

Also applies to: 57-57, 73-73, 82-82, 89-89, 106-106, 110-110, 114-114, 117-118, 119-120, 124-124, 154-154, 163-163, 168-168, 176-176, 201-201, 213-214, 216-216, 238-238, 256-256, 260-260, 282-282

VERSION.txt (1)

1-1: Version bump looks good

VERSION.txt correctly reflects 0.9.5.

example/example1/requirements.txt (1)

7-7: Dependency pin update acknowledged

The example now requires openfga-sdk >= 0.9.5. Matches the release bump.

openfga_sdk/__init__.py (1)

13-13: Good: single authoritative __version__ constant

Defining the version once here is the right approach; other modules/tests should reference this instead of embedding literals.

openfga_sdk/rest.py (1)

281-286: LGTM! Excellent fix for aiohttp response body handling.

This change correctly addresses the issue where aiohttp.ClientResponse.data needs to be awaited. The implementation:

  • Properly checks if the response is an aiohttp.ClientResponse without existing data attribute
  • Reads the response body asynchronously only when needed
  • Makes the response body available to downstream error handlers
  • Maintains the existing error handling logic

The fix is efficient as it only reads the response body once and only when necessary for error handling.

test/rest_test.py (2)

17-17: Appropriate import addition for test support.

The aiohttp import is necessary to support the new test's mock specifications.


187-210: Excellent test coverage for the response body reading fix.

This test comprehensively verifies the fix works correctly:

  • Properly mocks aiohttp.ClientResponse with error status (400)
  • Mocks the read method to return test data
  • Verifies ValidationException is raised for 400 status
  • Asserts that read was awaited exactly once
  • Confirms the data attribute is set with the correct value

The test provides solid coverage for the bug fix and ensures the response body reading behavior works as expected.

docs/OpenFgaApi.md (1)

782-782: Documentation clarification looks good.

This appears to be a formatting improvement to the Read API documentation without changing the semantic content or functionality. The examples and explanations remain consistent and clear.

@evansims evansims enabled auto-merge July 9, 2025 19:17
@evansims evansims added this pull request to the merge queue Jul 9, 2025
Merged via the queue into main with commit c87c8d2 Jul 9, 2025
28 checks passed
@evansims evansims deleted the release/v0.9.5 branch July 9, 2025 20:38
This was referenced Sep 12, 2025
@coderabbitai coderabbitai bot mentioned this pull request Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants