openfga / language

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

Validation location errors found in java implementation #259

Closed d-jeffery closed 1 month ago

d-jeffery commented 4 months ago

Found some validation errors when using the latest java build from main;

Incorrect highlight of definition name, instead of type reference; image

All errors being assigned to first occurrence of type reference; image

d-jeffery commented 4 months ago

If given a definition where the relation name and direct relation are the same word - the type is highlighted instead https://github.com/openfga/language/blob/main/pkg/js/util/exceptions.ts#L433

Test case:


- name: invalid type error maps to wrong location when duplicate relation name is used in direct assignment
  dsl: |
    model
      schema 1.1
    type custome
    type bank
      relations
        define customer : [customer]
    type account
      relations
        define owner : [customer]
  expected_errors:
    - msg: "`customer` is not a valid type."
      line:
        start: 5
        end: 5
      column:
        start: 23
        end: 31
      metadata:
        errorType: invalid-type
    - msg: "`customer` is not a valid type."
      line:
        start: 8
        end: 8
      column:
        start: 20
        end: 28
      metadata:
        errorType: invalid-type