$ cat /Users/miparnisari/Documents/GitHub/spicedb-vscode/syntaxes/test/imported.zed
use partial
definition user {}
partial secret {
relation secretview: user | notfound
permission view = blah
}
[20:02:17] ~/Documents/GitHub/zed (tstirrat/bring-in-new-schemadsl) $ ./zed validate /Users/miparnisari/Documents/GitHub/spicedb-vscode/syntaxes/test/imported.zed
Success! - 0 relationships loaded, 0 assertions run, 0 expected relations validated
In the file above, i expected zed validate to fail because notfound definition does not exist.
However, the validation of partials is only taking place when you use the partial somewhere.
This is slighlty problematic for VS Code users because the error is shown in the wrong place. E.g. if i use a partial in root.zed, the VS Code UI will point the error in root.zed even though it is in imported.zed. This is because its surfacing as a post-compilation error, and by that time, we don't know about partials anymore, so we lose information about the exact location of a relation definition.
There is a failing unit test here:
|
// TODO this doesn't pass |
|
//// broken2.zed has one error |
|
// resp, _ = sendAndReceive[FullDocumentDiagnosticReport](tester, "textDocument/diagnostic", |
|
// TextDocumentDiagnosticParams{ |
|
// TextDocument: TextDocument{URI: "file:///testdir/broken2.zed"}, |
|
// }) |
|
// require.Equal(t, "full", resp.Kind) |
|
// require.Len(t, resp.Items, 1) |
|
// require.Equal(t, lsp.Error, resp.Items[0].Severity) |
|
// require.Contains(t, resp.Items[0].Message, "could not lookup definition `organization` for relation `viewer`: object definition `organization` not found")} |
|
} |
In the file above, i expected
zed validateto fail becausenotfounddefinition does not exist.However, the validation of
partialsis only taking place when you use the partial somewhere.This is slighlty problematic for VS Code users because the error is shown in the wrong place. E.g. if i use a partial in
root.zed, the VS Code UI will point the error inroot.zedeven though it is inimported.zed. This is because its surfacing as a post-compilation error, and by that time, we don't know about partials anymore, so we lose information about the exact location of a relation definition.There is a failing unit test here:
spicedb/internal/lsp/lsp_test.go
Lines 464 to 474 in b041b8f