openfga/vscode-ext

Syntax highlighting parser error

jon-whit opened this issue · 4 comments

In v0.2.20 I notice a syntax highlighting bug.

Screenshot 2024-04-01 at 10 21 26 AM

It looks like the parser is not accurately recognizing the closing ] of the type restriction definition.

Reloaded VSCode and everything worked fine. No action needed.

A reload/restart fixed the original reported issue in the original description, but I'm seeing the issue again with models involving conditions. If I restart VSCode and start writing standard FGA models using the with keyword I start seeing errors from the language server.

Screenshot 2024-04-01 at 10 44 30 AM

Here is a stacktrace from the OpenFGA Language server output:

Error: Illegal argument: character must be non-negative
	at b (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:10:1101)
	at new w (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:148:4602)
	at new o (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:148:6067)
	at R (/Users/jonwhit/.vscode/extensions/openfga.openfga-vscode-0.2.20/client/out/extension.node.js:1:340988)
	at C (/Users/jonwhit/.vscode/extensions/openfga.openfga-vscode-0.2.20/client/out/extension.node.js:1:339973)
	at c (/Users/jonwhit/.vscode/extensions/openfga.openfga-vscode-0.2.20/client/out/extension.node.js:1:384924)
	at t.map (/Users/jonwhit/.vscode/extensions/openfga.openfga-vscode-0.2.20/client/out/extension.node.js:1:385010)
	at Object.asDiagnostics (/Users/jonwhit/.vscode/extensions/openfga.openfga-vscode-0.2.20/client/out/extension.node.js:1:352537)
	at isDisposed.client.isRunning.client.sendRequest.then.client.handleFailedRequest.kind (/Users/jonwhit/.vscode/extensions/openfga.openfga-vscode-0.2.20/client/out/extension.node.js:1:278989)
	at async m.pullAsync (/Users/jonwhit/.vscode/extensions/openfga.openfga-vscode-0.2.20/client/out/extension.node.js:1:275658)

Exception coming from language with column: { start: 0, end: 1 }.

When the condition-not-defined is a single character (in this case c), it appears that the column data returned is incorrect. Digging.

ModelValidationSingleError: condition-not-defined error at line=8, column=0: `c` is not a defined condition in the model.
    at constructValidationError (/Users/daniel.jeffery/VSCodeProjects/vscode-ext/server/out/server.node.js:25940:12)
    at createInvalidConditionNameInParameterError (/Users/daniel.jeffery/VSCodeProjects/vscode-ext/server/out/server.node.js:25735:17)
    at ExceptionCollector.raiseInvalidConditionNameInParameter (/Users/daniel.jeffery/VSCodeProjects/vscode-ext/server/out/server.node.js:26060:9)
    at childDefDefined (/Users/daniel.jeffery/VSCodeProjects/vscode-ext/server/out/server.node.js:11997:31)
    at relationDefined (/Users/daniel.jeffery/VSCodeProjects/vscode-ext/server/out/server.node.js:12109:13)
    at /Users/daniel.jeffery/VSCodeProjects/vscode-ext/server/out/server.node.js:12141:13
    at Array.forEach (<anonymous>)
    at modelValidation (/Users/daniel.jeffery/VSCodeProjects/vscode-ext/server/out/server.node.js:12137:88)
    at validateJSON (/Users/daniel.jeffery/VSCodeProjects/vscode-ext/server/out/server.node.js:12299:13)
    at Object.validateDSL (/Users/daniel.jeffery/VSCodeProjects/vscode-ext/server/out/server.node.js:12325:5) {
  properties: {
    msg: '`c` is not a defined condition in the model.',
    file: undefined,
    line: { start: 8, end: 8 },
    column: { start: 0, end: 1 }
  },
  type: 'condition-not-defined',
  line: { start: 8, end: 8 },
  column: { start: 0, end: 1 },
  msg: '`c` is not a defined condition in the model.',
  file: undefined,
  metadata: {
    symbol: 'c',
    errorType: 'condition-not-defined',
    module: undefined,
    relation: 'viewer',
    type: 'document'
  }
}```

Fix: openfga/language#219 - error occurred when condition name was a single character long.

This same codeblock is a pattern else where, but this change + test looks fixed.