Skip to content
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

TupleKey should support relation=None #95

Open
6 tasks done
jnu opened this issue Jun 5, 2024 · 2 comments
Open
6 tasks done

TupleKey should support relation=None #95

jnu opened this issue Jun 5, 2024 · 2 comments
Labels
bug Something isn't working waiting-user-feedback

Comments

@jnu
Copy link

jnu commented Jun 5, 2024

Checklist

  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have upgraded to the latest version of OpenFGA and the issue still persists.
  • I have searched the Slack community and have not found a suitable solution or answer.
  • I agree to the terms within the OpenFGA Code of Conduct.

Description

The docs describe how to use the read() method with a TupleKey with no relation set to get a list of all relations a user has with an object. Currently the TupleKey object validation prevents the relation from being None.

Expectation

Not to throw an error when omitting relation or setting to None.

Reproduction

Essentially the code from the docs:

body = TupleKey(
            user="user:bob",
            object="document:123",

)

Working around the validation and submitting the query confirms the behavior describes from the docs (i.e., listing the relations) works as expected:

Issuing a query with a workaround:

body = TupleKey(
            user="user:bob",
            relation="",
            object="document:123",

)
body._relation = None

# call `read(body)` ...

OpenFGA SDK version

0.4.0 (but the code in main appears broken)

OpenFGA version

v1.5.0

SDK Configuration

[default options]

Logs

No response

References

No response

@jnu jnu added the bug Something isn't working label Jun 5, 2024
@rhamzeh
Copy link
Member

rhamzeh commented Jun 6, 2024

Hi @jnu - Thanks for raising this! I will transfer this to be an issue in the docs, the SDK docs here are more up to date

https://github.com/openfga/python-sdk?tab=readme-ov-file#read-relationship-tuples

And you would want to do something like

# from openfga_sdk import OpenFgaClient, ReadRequestTupleKey

# Initialize the fga_client
# fga_client = OpenFgaClient(configuration)

# Find all relationship tuples where a certain user has a relationship as any relation to a certain document
body = ReadRequestTupleKey(
    user="user:81684243-9356-4421-8fbf-a4f8d36aa31b",
    object="document:roadmap",
)

response = await fga_client.read(body)
# response = ReadResponse({"tuples": [Tuple({"key": TupleKey({"user":"...","relation":"...","object":"..."}), "timestamp": datetime.fromisoformat("...") })]})

@rhamzeh
Copy link
Member

rhamzeh commented Jun 6, 2024

Before we move it, can you clarify:

0.4.0 (but the code in main appears broken)

Is there something else not working for you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting-user-feedback
Projects
Status: Backlog
Development

No branches or pull requests

2 participants