Skip to content

Validation of partials occurs only after you use the partial somewhere #2982

@miparnisari

Description

@miparnisari
$ 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")}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/schemaAffects the Schema Languagekind/bugSomething is broken or regressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions