Skip to content

Conversation

@ewanharris
Copy link
Member

@ewanharris ewanharris commented Oct 15, 2025

Description

Generator PR for openfga/java-sdk#234

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
    • Added conflict-handling options for write operations: choose how to handle duplicates on writes (onDuplicate) and missing tuples on deletes (onMissing). Available across single writes, bulk writes, and deletes. Requires OpenFGA v1.10.0+.
  • Documentation
    • Expanded README with guidance and examples for using onDuplicate and onMissing in write/delete operations.
  • Tests
    • Added comprehensive tests covering onDuplicate/onMissing options in transactional and non-transactional paths.
  • Chores
    • Updated default OpenFGA version used in tooling to v1.10.2.

@ewanharris ewanharris requested a review from a team as a code owner October 15, 2025 14:24
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds conflict-handling options to Java client write/delete requests by threading onDuplicate (writes) and onMissing (deletes) through client methods and builders. Introduces new option fields in configuration classes, updates request construction, and extends tests. Documents usage in README. Bumps OpenFGA Docker tag to v1.10.2.

Changes

Cohort / File(s) Summary
Docs
config/clients/java/template/README_calling_api.mustache
Adds documentation for conflict options in write operations, usage examples, and required OpenFGA version (v1.10.0+).
Client core
config/clients/java/template/src/main/api/client/OpenFgaClient.java.mustache
Threads options into request builders: passes onDuplicate for writes and onMissing for deletes in both transactional and non-transactional paths; updates writeTuples/deleteTuples helpers to include options.
Model helpers
config/clients/java/template/src/main/api/client/model/ClientTupleKey.java.mustache, .../model/ClientTupleKeyWithoutCondition.java.mustache
Adds overloaded builders: asWriteRequestWrites(..., onDuplicate) and asWriteRequestDeletes(..., onMissing); legacy methods delegate with null. Conditional application of options.
Options/configuration
.../configuration/ClientWriteOptions.java.mustache, .../configuration/ClientWriteTuplesOptions.java.mustache, .../configuration/ClientDeleteTuplesOptions.java.mustache
Introduces new fields and accessors: onDuplicate (WriteRequestWrites.OnDuplicateEnum) and onMissing (WriteRequestDeletes.OnMissingEnum) across relevant option classes; adds necessary imports and fluent setters/getters.
API tests
config/clients/java/template/src/test/api/OpenFgaApiTest.java.mustache
Adds tests covering onDuplicate (IGNORE/ERROR) and onMissing (IGNORE/ERROR), including combined options; updates expected payloads to include on_duplicate/on_missing.
Client tests
config/clients/java/template/src/test/api/client/OpenFgaClientTest.java.mustache
Updates payload expectations to include on_duplicate/on_missing; adds new tests for transactional and non-transactional flows with options; extends assertions.
Build/config
config/common/config.base.json
Updates openFGADockerTag from v1.5.1 to v1.10.2.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant App as Application
  participant Client as OpenFgaClient
  participant Builder as Request Builders
  participant API as OpenFGA API

  App->>Client: write(tupleKeys, options{onDuplicate, onMissing})
  Client->>Builder: asWriteRequestWrites(tupleKeys, onDuplicate)
  note over Builder: Conditionally set on_duplicate if provided
  Builder-->>Client: WriteRequest.writes
  Client->>Builder: asWriteRequestDeletes(tupleKeysToDelete, onMissing)
  note over Builder: Conditionally set on_missing if provided
  Builder-->>Client: WriteRequest.deletes
  Client->>API: POST /stores/{id}/write {writes, deletes, on_duplicate/on_missing embedded}
  API-->>Client: 200 OK (transaction/write response)
  Client-->>App: Result
Loading
sequenceDiagram
  autonumber
  participant App as Application
  participant Client as OpenFgaClient
  participant Builder as Request Builders
  participant API as OpenFGA API

  App->>Client: deleteTuples(keys, options{onMissing})
  Client->>Builder: asWriteRequestDeletes(keys, onMissing)
  Builder-->>Client: WriteRequest
  Client->>API: POST /write {deletes with on_missing}
  API-->>Client: 200 OK
  Client-->>App: Result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • jimmyjames
  • sergiught

Pre-merge checks and finishing touches

✅ 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 accurately and concisely captures the main feature of the pull request by describing the addition of write conflict settings support in the Java SDK, which aligns with the modifications to client options, API methods, documentation, and tests. It uses clear, specific language without unnecessary detail or noise, making it easy for a reviewer scanning history to understand the purpose.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

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.

@jimmyjames jimmyjames added this pull request to the merge queue Oct 15, 2025
Merged via the queue into main with commit 75dbea2 Oct 15, 2025
19 checks passed
@jimmyjames jimmyjames deleted the feat/java-write-options branch October 15, 2025 19:39
@dyeam0 dyeam0 linked an issue Oct 23, 2025 that may be closed by this pull request
1 task
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.

[All SDKs] Add on_duplicate/on_missing options support for Write operations

2 participants