-
Notifications
You must be signed in to change notification settings - Fork 24
feat: add support for write conflict settings #276
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
feat: add support for write conflict settings #276
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughThe PR adds support for write-operation conflict options (on_duplicate for duplicate writes, on_missing for missing deletes) across the SDK by introducing new API model enums, client configuration interfaces, updated method signatures, and comprehensive documentation and test coverage. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes The PR spans multiple files with consistent pattern changes (new enums, interfaces, and option propagation). While the logic is relatively straightforward—adding optional conflict configuration that flows through to API calls—understanding the complete implementation requires reviewing type definitions, client method modifications, documentation, and test scenarios across the codebase. Possibly related issues
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
|
No dependency changes detected. Learn more about Socket for GitHub. 👍 No dependency changes detected in pull request |
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: 2
🧹 Nitpick comments (1)
example/example1/example1.mjs (1)
149-151: Use exported enum for conflict option.Since we now surface
OnDuplicateWrites, please lean on that constant instead of the raw string so the example mirrors the public API surface.-import { CredentialsMethod, FgaApiValidationError, OpenFgaClient, TypeName } from "@openfga/sdk"; +import { CredentialsMethod, FgaApiValidationError, OnDuplicateWrites, OpenFgaClient, TypeName } from "@openfga/sdk"; @@ }, { authorizationModelId, - conflict: { onDuplicateWrites: 'ignore' } + conflict: { onDuplicateWrites: OnDuplicateWrites.Ignore } });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (6)
README.md(1 hunks)api.ts(4 hunks)apiModel.ts(2 hunks)client.ts(9 hunks)example/example1/example1.mjs(1 hunks)tests/client.test.ts(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
tests/client.test.ts (2)
client.ts (2)
OnDuplicateWrites(192-192)OnMissingDeletes(194-194)tests/helpers/default-config.ts (1)
baseConfig(54-67)
client.ts (1)
apiModel.ts (2)
TupleKey(1432-1457)TupleKeyWithoutCondition(1463-1482)
e23c5e3 to
a019ea2
Compare
|
Thanks for your submission @phamhieu. We will assign someone to review your PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #276 +/- ##
==========================================
+ Coverage 89.13% 89.45% +0.32%
==========================================
Files 24 24
Lines 1288 1299 +11
Branches 211 234 +23
==========================================
+ Hits 1148 1162 +14
+ Misses 84 81 -3
Partials 56 56 ☔ 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.
Pull Request Overview
This PR adds support for write conflict handling options introduced in OpenFGA v1.10.0, enabling developers to control behavior when writing duplicate tuples or deleting non-existent tuples.
- Added
OnDuplicateWritesandOnMissingDeletesenums withErrorandIgnoreoptions - Extended
write,writeTuples, anddeleteTuplesmethods to accept conflict configuration - Updated API documentation to reflect the new conflict handling behavior
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| apiModel.ts | Added on_duplicate and on_missing fields to write/delete request interfaces with corresponding enums |
| client.ts | Extended client interfaces and methods to support conflict options with proper type safety |
| api.ts | Updated API documentation to describe conflict handling behavior and examples |
| tests/client.test.ts | Added comprehensive test coverage for conflict options across write, writeTuples, and deleteTuples methods |
| example/example1/example1.mjs | Demonstrated usage of conflict options in example code |
| README.md | Added detailed documentation section explaining conflict options usage and behavior |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
SoulPancake
left a comment
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.
LG, Thanks a lot @phamhieu
SoulPancake
left a comment
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.
@phamhieu Would it be possible for you to take a look at the lockfile changes once? I think it might be related to the latest merge
https://github.com/openfga/js-sdk/actions/runs/18768778003/job/53559732838#step:4:9
The CI check is currently failing because of this
2fa3e77 to
bb062f5
Compare
Fixed! I've resolved the conflicts. |
SoulPancake
left a comment
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.
LGTM, Thanks a lot @phamhieu
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.
Thank you for the submission—this is a solid PR overall.
I left a few focused comments to avoid overwhelming the review. There are still areas to address, notably:
-
Complete test coverage of write/delete conflict combinations and defaults.
-
Error-path tests (4xx/5xx mapping), timeouts/abort, and transaction options (chunking/concurrency).
-
Naming/typing consistency (singular option names, remove “Enum” suffix, prefer final types).
Happy to re-review once these are incorporated.
SoulPancake
left a comment
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.
LG
rhamzeh
left a comment
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.
Oh and @phamhieu - one more minor thing, would you mind adding the Changelog entry for this change in the unreleased section?
Something like:
- feat: add support for conflict options for Write operations**: (#276)
The client now supports setting `conflict` on `ClientWriteRequestOpts` to control behavior when writing duplicate tuples or deleting non-existent tuples. This feature requires OpenFGA server [v1.10.0](https://github.com/openfga/openfga/releases/tag/v1.10.0) or later.
See [Conflict Options for Write Operations](./README.md#conflict-options-for-write-operations) for more.
|
Thanks @phamhieu ! |
|
@daniel-jonathan Could you give this a final review? I’d love to get it merged since I need this feature for my project. |
Description
Adds support for write conflict options in the JavaScript SDK to handle duplicate writes and missing deletes, as introduced in OpenFGA v1.10.0.
This implementation adds
onDuplicateWritesandonMissingDeletesoptions to control behavior when:onDuplicateWrites)onMissingDeletes)References
Review Checklist
mainSummary by CodeRabbit
New Features
OnDuplicateWritesandOnMissingDeletesto control behavior when duplicates are encountered or tuples are missing during deletes.Documentation