Skip to content

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

@rhamzeh

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 idempotency options in the SDK client interface.

As an example for Go (each SDK should follow it's own similar conventions), the client should support the following options through ClientWriteOptions.Conflict:

  • OnDuplicateWrites: Controls behavior when writing a tuple that already exists
    CLIENT_WRITE_REQUEST_ON_DUPLICATE_WRITES_IGNORE - Silently skip duplicate writes
  • CLIENT_WRITE_REQUEST_ON_DUPLICATE_WRITES_ERROR - Return error on duplicates (default)
    OnMissingDeletes: Controls behavior when deleting a tuple that doesn't exist
  • CLIENT_WRITE_REQUEST_ON_MISSING_DELETES_IGNORE - Silently skip missing deletes
  • CLIENT_WRITE_REQUEST_ON_MISSING_DELETES_ERROR - Return error on missing deletes (default)
options := client.ClientWriteOptions{
    Conflict: client.ConflictOptions{
        OnDuplicateWrites: client.CLIENT_WRITE_REQUEST_ON_DUPLICATE_WRITES_ERROR,
        OnMissingDeletes: client.CLIENT_WRITE_REQUEST_ON_MISSING_DELETES_IGNORE,
    },
}

If the user does not specify the behavior, the default value as specified by the API should be sent.

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

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    dotnet-sdkAffects the C#/DotNet SDKenhancementNew feature or requestgo-sdkAffects the Go SDKjava-sdkAffects the Java/Kotlin SDKjs-sdkAffects the JavaScript SDKpython-sdkAffects the Python SDKruby-sdk

    Projects

    Status

    In review

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions