Skip to content

Conversation

rhamzeh
Copy link
Member

@rhamzeh rhamzeh commented Jul 1, 2025

Description

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

  • Documentation

    • Updated the README to clarify that the order of results from batch check queries is not guaranteed and recommend using the correlation ID to match responses.
    • Renamed the "Auth0 Client Credentials" heading to "Client Credentials" in client initialization examples.
  • Bug Fixes

    • Improved handling of optional parameters in batch check requests to ensure consistency and authorization model ID are correctly set when provided.
  • Tests

    • Added a test to verify batch check requests with options for authorization model ID and consistency.

@rhamzeh rhamzeh requested review from a team as code owners July 1, 2025 19:45
Copy link
Contributor

coderabbitai bot commented Jul 1, 2025

Walkthrough

The changes update documentation and implementation related to batch check requests in the client. The documentation clarifies result ordering and renames a section. Implementation updates ensure optional parameters like authorization model ID and consistency are included in batch check requests, with corresponding telemetry and a new test verifying this behavior.

Changes

File(s) Change Summary
README.md Renamed "Auth0 Client Credentials" to "Client Credentials" and added a note clarifying that batchCheck results may not match input order, recommending use of correlationId.
src/main/java/dev/openfga/sdk/api/OpenFgaApi.java Enhanced telemetry attribute collection in buildTelemetryAttributes to include authorizationModelId from BatchCheckRequest if present.
src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java Modified batchCheck to set consistency and authorizationModelId in the request, using options if provided, otherwise falling back to client defaults.
src/main/java/dev/openfga/sdk/api/model/AbstractOpenApiSchema.java Simplified the isNullable() method by removing an unnecessary else block; logic unchanged.
src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java Added batchCheck_withOptions test to verify batchCheck correctly sends optional authorizationModelId and consistency fields and processes the response.

Sequence Diagram(s)

sequenceDiagram
    participant ClientApp
    participant OpenFgaClient
    participant OpenFgaApi

    ClientApp->>OpenFgaClient: batchCheck(request, options)
    OpenFgaClient->>OpenFgaClient: Build BatchCheckRequest\n(set checks, consistency, authorizationModelId)
    OpenFgaClient->>OpenFgaApi: batchCheck(BatchCheckRequest)
    OpenFgaApi->>OpenFgaApi: Collect telemetry attributes\n(including authorizationModelId)
    OpenFgaApi-->>OpenFgaClient: BatchCheckResponse
    OpenFgaClient-->>ClientApp: ClientBatchCheckResponse
Loading

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.38.1)
src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java
✨ 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-commenter commented Jul 1, 2025

Codecov Report

Attention: Patch coverage is 78.57143% with 3 lines in your changes missing coverage. Please review.

Project coverage is 33.66%. Comparing base (71ddedc) to head (6098ad8).

Files with missing lines Patch % Lines
src/main/java/dev/openfga/sdk/api/OpenFgaApi.java 66.66% 0 Missing and 1 partial ⚠️
...java/dev/openfga/sdk/api/client/OpenFgaClient.java 90.00% 0 Missing and 1 partial ⚠️
...v/openfga/sdk/api/model/AbstractOpenApiSchema.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #175      +/-   ##
============================================
+ Coverage     33.42%   33.66%   +0.23%     
- Complexity      994     1003       +9     
============================================
  Files           182      182              
  Lines          6878     6889      +11     
  Branches        772      776       +4     
============================================
+ Hits           2299     2319      +20     
+ Misses         4476     4466      -10     
- Partials        103      104       +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: 0

🧹 Nitpick comments (4)
src/main/java/dev/openfga/sdk/api/model/AbstractOpenApiSchema.java (1)

137-142: Further condense isNullable() logic

Good removal of the dead else, but the whole method can now be expressed in a single line while keeping behaviour identical:

-    public Boolean isNullable() {
-        if (Boolean.TRUE.equals(isNullable)) {
-            return Boolean.TRUE;
-        }
-        return Boolean.FALSE;
-    }
+    public Boolean isNullable() {
+        // Autoboxes the primitive boolean back to a `Boolean`
+        return Boolean.TRUE.equals(isNullable);
+    }

Removes five lines, no functional change.

src/main/java/dev/openfga/sdk/api/OpenFgaApi.java (1)

1154-1161: Consolidate duplicated “add-model-id” blocks

Blocks that add the FGA_CLIENT_REQUEST_MODEL_ID attribute now exist for
CheckRequest, ExpandRequest, ListObjectsRequest, ListUsersRequest,
WriteRequest, and (new) BatchCheckRequest.
The code is starting to diverge and makes future updates error-prone.

Extracting the repeated fragment into a tiny helper keeps buildTelemetryAttributes
tight and guarantees identical trimming/validation rules across request
types, e.g.:

private void maybeAddModelId(String id, Map<Attribute,String> attrs) {
    if (!isNullOrWhitespace(id)) {
        attrs.put(Attributes.FGA_CLIENT_REQUEST_MODEL_ID, id);
    }
}

Then each branch becomes a one-liner:

if (body instanceof BatchCheckRequest batch) {
    maybeAddModelId(batch.getAuthorizationModelId(), telemetryAttributes);
    ...
}

Net effect: less duplication, easier maintenance.

README.md (2)

177-177: Check/adjust anchor references after heading rename

#### Client Credentials looks good, but any existing Markdown links (e.g., in the Table of Contents or elsewhere in the repo) that still point to #auth0-client-credentials will now break. Search-and-replace those anchors or add an explicit id to keep back-compat.


608-609: Remove stray blank line inside the blockquote

markdownlint complains (MD028) because the empty > line breaks the blockquote:

-> **Note**: The order of `batchCheck` results is not guaranteed to match the order of the checks provided. Use `correlationId` to pair responses with requests.
->
+> **Note**: The order of `batchCheck` results is not guaranteed to match the order of the checks provided. Use `correlationId` to pair responses with requests.

Deleting the blank line resolves the linter warning and keeps the rendered note compact.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 71ddedc and 6098ad8.

📒 Files selected for processing (5)
  • README.md (2 hunks)
  • src/main/java/dev/openfga/sdk/api/OpenFgaApi.java (1 hunks)
  • src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java (1 hunks)
  • src/main/java/dev/openfga/sdk/api/model/AbstractOpenApiSchema.java (1 hunks)
  • src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/main/java/dev/openfga/sdk/api/OpenFgaApi.java (1)
src/main/java/dev/openfga/sdk/telemetry/Attributes.java (1)
  • Attributes (31-216)
🪛 markdownlint-cli2 (0.17.2)
README.md

609-609: Blank line inside blockquote

(MD028, no-blanks-blockquote)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Test and Build OpenFGA (11)
  • GitHub Check: Test and Build OpenFGA (21)
  • GitHub Check: Test and Build OpenFGA (17)
  • GitHub Check: Analyze (java)
🔇 Additional comments (2)
src/test/java/dev/openfga/sdk/api/client/OpenFgaClientTest.java (1)

2043-2074: LGTM! Well-structured test for batchCheck with options.

This test effectively verifies that the batchCheck method properly includes optional parameters (authorizationModelId and consistency) in the request body when provided via ClientBatchCheckOptions. The test follows established patterns, uses proper mocking, and includes comprehensive assertions for both the HTTP interaction and response validation.

src/main/java/dev/openfga/sdk/api/client/OpenFgaClient.java (1)

714-730: LGTM! Well-implemented enhancement for parameter handling.

The updated lambda expression properly handles optional consistency and authorizationModelId parameters in batch check requests. The implementation follows the established pattern used throughout this class, correctly prioritizing option values over configuration defaults and including appropriate null/whitespace checks.

This change brings the batchCheck method in line with other similar methods like check, expand, and listObjects, ensuring consistent parameter handling across the client.

@rhamzeh rhamzeh added this pull request to the merge queue Jul 1, 2025
Merged via the queue into main with commit 2c42f8d Jul 1, 2025
24 checks passed
@rhamzeh rhamzeh deleted the feat/regenerate branch July 1, 2025 20:23
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.

5 participants