-
Notifications
You must be signed in to change notification settings - Fork 33
release: v0.9.5 #200
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
release: v0.9.5 #200
Conversation
WalkthroughThis 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 Changes
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
Possibly related PRs
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❌ 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. 🚀 New features to boost your workflow:
|
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: 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_AGENTeverywhere.
♻️ Duplicate comments (2)
openfga_sdk/oauth2.py (1)
82-87: Duplicate hard-coded User-Agent (see sync variant)
Same DRY concern as insync/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 aboveReplicate 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
VERSIONhere now duplicates the constant inopenfga_sdk/__init__.pyand 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.pymodule 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.metadatareads distribution metadata without importing theopenfga_sdkpackage itself.test/sync/oauth2_test.py (1)
83-88: DeriveUser-Agentexpectation 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 furtherGood call-out on the ordering guarantee. Consider adding a short example showing how
correlation_idcan 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-agentEvery 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 releasesPrior entries use the
vprefix (v0.9.4,v0.9.3, …) while the new links point to plain0.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 versionThese 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 authorityThe 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 headersHard-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 stringSame issue as above—replace the literal
0.9.5withopenfga_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 breaksThe 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 inread_with_http_infoDuplicating the giant one-liner in the
_with_http_infovariant 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 compatThe new sentence is ~1 600 chars long. Sphinx, IDE hovers, and plain
pydocall 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 inread_with_http_infodocstringSame extremely long line appears here. Apply the same wrapping as suggested
forreadto avoid repeated lint / doc-build warnings and improve
maintainability.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 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 concernsAll 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.txtcorrectly reflects 0.9.5.example/example1/requirements.txt (1)
7-7: Dependency pin update acknowledgedThe example now requires
openfga-sdk >= 0.9.5. Matches the release bump.openfga_sdk/__init__.py (1)
13-13: Good: single authoritative__version__constantDefining 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.dataneeds to be awaited. The implementation:
- Properly checks if the response is an
aiohttp.ClientResponsewithout existingdataattribute- 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
aiohttpimport 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.ClientResponsewith error status (400)- Mocks the
readmethod to return test data- Verifies
ValidationExceptionis raised for 400 status- Asserts that
readwas awaited exactly once- Confirms the
dataattribute is set with the correct valueThe 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.
0.9.5 (2025-07-09)
Generated from → openfga/sdk-generator#570
Summary by CodeRabbit
Bug Fixes
Documentation
Chores
Tests