zed icon indicating copy to clipboard operation
zed copied to clipboard

zed import ignores value of --schema-definition-prefix when referencing caveats

Open zd9KgA opened this issue 1 year ago • 0 comments

With file import.yaml as:

schema: |-2
  definition user {}

  caveat only_on_tuesday(day_of_week string) {
    day_of_week == 'tuesday'
  }

  definition document {
      relation reader: user | user with only_on_tuesday

      permission view = reader
  }

the following unexpected behavior can be observed:

$ zed  import --schema=True --relationships=True --schema-definition-prefix=authzed import.yaml
> INF importing schema
> ERR terminated with errors error="rpc error: code = FailedPrecondition desc = could not lookup caveat `only_on_tuesday` for relation `reader`: caveat `only_on_tuesday` not found"
$ zed version
> client: zed v0.17.1
> ...
> service: v1.30.0

This can be "fixed" by prefixing the reference of "only_on_tuesday" by the intended permission system prefix "authzed/".

The expected behavior is that the import works for the example as is, that is, that the permission system is automatically prefixed to caveat references as well.

zd9KgA avatar Apr 16 '24 13:04 zd9KgA