Incorrect implementation of `tuple.SplitObject`
Checklist
- [X] I have looked into the README and have not found a suitable solution or answer.
- [X] I have looked into the documentation and have not found a suitable solution or answer.
- [X] I have searched the issues and have not found a suitable solution or answer.
- [X] I have upgraded to the latest version of OpenFGA and the issue still persists.
- [X] I have searched the OpenFGA Community and have not found a suitable solution or answer.
- [X] I agree to the terms within the OpenFGA Code of Conduct.
Description
It seems to me that tuple.SplitObject(obj) is incorrectly implemented.
- it supports an input such as
group#member:fga, which is invalid. - for a valid input
group:fga#memberit returnsgroup, fga#member. It should begroup,member,fga.
Luckily, when we pass a userset as input, we always discard the second return value, so this doesn't manifest in any bugs.
Expectation
tuple.SplitObjectshould accept correctly formatted usersets as inputs.- If it's possible, I recommend changing the return types from
(typeAndRelation, id)to(type, relation, id)and deprecateSplitObjectRelation. These two functions almost always are called together, which is a code smell.
Reproduction
n/a
Store data
No response
OpenFGA version
1.5.7
How are you running OpenFGA?
As a binary
What datastore are you using?
In-Memory
OpenFGA Flags
none
Logs
No response
Hey @miparnisari , I've been looking for a good issue to start contributing and I saw this one referenced in https://github.com/openfga/openfga/pull/1615#discussion_r1747483797. Do you think it's an appropriate time for me to pick this one up since it has a bunch of references throughout the code?
Hey @Jguer! You can try to do it, but i'm honestly not sure if it will be an easy first task since like you said it's being referenced in a bunch of places. You will likely experience unit test failures. I recommend timeboxing the refactor to half an hour and then publish a PR, and we can take it from there if you wish.
@miparnisari just a sidenote: group:fga#member is an invalid object, I don't think it should return group, member, fga.
Unless you want a SplitUserset
@rhamzeh yes, if anything, SplitObject should have been called SplitUserset 😓
using tuple.ToUserParts will get rid of the ambiguity.