Skip to content

Commit

Permalink
fix: but not in go parser + fix error message for unsupported relations
Browse files Browse the repository at this point in the history
  • Loading branch information
rhamzeh committed Dec 8, 2023
1 parent 24584eb commit d41ed33
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/go/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
var ErrUnsupportedJSON = errors.New("json not currently supported by dsl")

func UnsupportedDSLNestingError(typeName string, relationName string) error {
return fmt.Errorf("the '%s' relation under the '%s' type has mixed operators which are not supported by the OpenFGA DSL syntax yet", relationName, typeName)
return fmt.Errorf("the '%s' relation definition under the '%s' type is not supported by the OpenFGA DSL syntax yet", relationName, typeName)
}

func ConditionNameDoesntMatchError(conditionName string, conditionNestedName string) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/go/transformer/dsltojson.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (l *OpenFgaDslListener) EnterRelationDefPartials(ctx *parser.RelationDefPar
l.currentRelation.Operator = RELATION_DEFINITION_OPERATOR_OR
} else if len(ctx.AllAND()) > 0 {
l.currentRelation.Operator = RELATION_DEFINITION_OPERATOR_AND
} else if len(ctx.AllBUT_NOT()) > 0 {
} else if ctx.BUT_NOT() != nil {
l.currentRelation.Operator = RELATION_DEFINITION_OPERATOR_BUT_NOT
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/js/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class UnsupportedDSLNestingError extends Error {
public relationName: string,
) {
super(
`the '${relationName}' relation under the '${typeName}' type has mixed operators which are not supported by the OpenFGA DSL syntax yet`,
`the '${relationName}' relation definition under the '${typeName}' type is not supported by the OpenFGA DSL syntax yet`,
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/data/json-syntax-transformer-validation-cases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
]
}
valid: false,
error_message: the 'rel2' relation under the 'user' type is not supported by the OpenFGA DSL syntax yet
error_message: the 'rel2' relation definition under the 'user' type is not supported by the OpenFGA DSL syntax yet

- name: mixed operators with direct assignment
json: >-2
Expand Down Expand Up @@ -195,7 +195,7 @@
]
}
valid: false,
error_message: the 'rel1' relation under the 'user' type is not supported by the OpenFGA DSL syntax yet
error_message: the 'rel1' relation definition under the 'user' type is not supported by the OpenFGA DSL syntax yet

- name: mixed operators with direct assignment
json: >-2
Expand Down Expand Up @@ -285,4 +285,4 @@
]
}
valid: false,
error_message: the 'rel4' relation under the 'user' type is not supported by the OpenFGA DSL syntax yet
error_message: the 'rel4' relation definition under the 'user' type is not supported by the OpenFGA DSL syntax yet

0 comments on commit d41ed33

Please sign in to comment.