openfga / language

Grammar for the OpenFGA modeling language
https://openfga.dev
Apache License 2.0
18 stars 7 forks source link

Unhelpful error message when using rewrites as the base (tupleset) of a `from` #68

Closed rhamzeh closed 2 months ago

rhamzeh commented 1 year ago
model
  schema 1.1
type user
type org
  relations
    define owner: [user]
    define member: [user]
    define can_add_member: owner
type team
  relations
    define parent: [org]
    define member: [user]
    define can_add_member: can_add_member from parent
type group
  relations
    define parent: [team]
    define org: parent from parent
    define member: [user]
    define can_add_member: can_add_member from org

The language server shows an unhelpful ModelValidationError:

`can_add_member` is an impossible relation for `group` (no entrypoint).

The actual error should inform the user the because group -> org has a rewrite (in this case tuple to userset, but computed usersets or a type restriction with a userset should also fail), it cannot be used as the source of a from (cannot be used as a tupleset).

The actual error message should be discussed.

The API shows a much more helpful message in similar situations:

the 'group#org' relation is referenced in at least one tupleset and thus must be a direct relation
Screenshot 2023-09-20 at 6 40 51 PM
d-jeffery commented 2 months ago

Is this the same case? or is it no entry? or both?

model
  schema 1.1
type user
type group
  relations
    define group: group from group
rhamzeh commented 2 months ago

Both apply I guess, but my preference would be no entry

d-jeffery commented 2 months ago

Both apply I guess, but my preference would be no entry

I think I can have it return both errors for the model in question. Is that desirable?

d-jeffery commented 2 months ago