Skip to content

Add conflict options support for Write operations #229

Description

@rhamzeh

Checklist

Describe the problem you'd like to have solved

Users spend a lot of time working around errors resulting from writing an already existing tuple or deleting a non-existent one.

Describe the ideal solution

OpenFGA v1.10.0 introduced support for write conflict options (on missing/on duplicate).

The SDKs must expose that in the underlying API client and models, as well as add support for conflict options in the SDK client interface.

As an example for Go, the client should support the following options through ClientWriteOptions.Conflict:

  • WritesOnDuplicate: Controls behavior when writing a tuple that already exists
    CLIENT_WRITE_REQUEST_WRITES_ON_DUPLICATE_IGNORE - Silently skip duplicate writes
  • CLIENT_WRITE_REQUEST_WRITES_ON_DUPLICATE_ERROR - Return error on duplicates (default)
    DeleteOnMissing: Controls behavior when deleting a tuple that doesn't exist
  • CLIENT_WRITE_REQUEST_DELETES_ON_MISSING_IGNORE - Silently skip missing deletes
  • CLIENT_WRITE_REQUEST_DELETES_ON_MISSING_ERROR - Return error on missing deletes (default)
options := client.ClientWriteOptions{
    Conflict: client.ConflictOptions{
        WritesOnDuplicate: client.CLIENT_WRITE_REQUEST_WRITES_ON_DUPLICATE_ERROR,
        DeleteOnMissing: client.CLIENT_WRITE_REQUEST_DELETES_ON_MISSING_IGNORE,
    },
}

If the user does not set the default, the SDK should not send it, relying on the server to implement its default behaviour.

Ensure that the:

  • Change has tests for both the OpenFgaApi and OpenFgaClient layers
  • The Write section in the README is appropriately updated
  • The unreleased section of the Changelog is updated

Alternatives and current workarounds

No response

References

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions