zed icon indicating copy to clipboard operation
zed copied to clipboard

validation file referencing schema using schemaFile cannot be imported

Open h3adache opened this issue 11 months ago • 6 comments

The new schemaFile syntax added in #455 is very nice but breaks imports.

zed import studio-entitlements-admin-server/src/main/resources/authzed/schema.zed.yaml
panic: interface conversion: interface {} is *decode.SchemaRelationships, not *validationfile.ValidationFile

goroutine 1 [running]:
github.com/authzed/zed/internal/decode.unmarshalAsYAMLOrSchemaWithFile({0x1400016e000, 0x3b8e, 0x4000}, {0x101b38340, 0x140000a8640}, {0x16f32a0e3, 0x4b})
        internal/decode/decoder.go:116 +0x224
github.com/authzed/zed/internal/decode.DecoderForURL.fileDecoder.func2({0x101b38340, 0x140000a8640})
        internal/decode/decoder.go:62 +0x9c
github.com/authzed/zed/internal/cmd.importCmdFunc(0x1028c4940, {0x140003c1c50, 0x1, 0x1?})
        internal/cmd/import.go:80 +0xa8
github.com/spf13/cobra.(*Command).execute(0x1028c4940, {0x140003c1c20, 0x1, 0x1})
        /Users/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:985 +0x834
github.com/spf13/cobra.(*Command).ExecuteC(0x140002da008)
        /Users/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1117 +0x344
github.com/spf13/cobra.(*Command).Execute(...)
        /Users/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1041
github.com/spf13/cobra.(*Command).ExecuteContext(...)
        /Users/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:1034
github.com/authzed/zed/internal/cmd.Run()
        internal/cmd/cmd.go:134 +0x7a8
main.main()
        cmd/zed/main.go:6 +0x1c

I suppose composable schema support would also fix this but just adding it in case it's something quick to support :)

h3adache avatar Jan 28 '25 19:01 h3adache

@h3adache is this specifically for a validation file that includes a schemaFile reference? I'm having trouble reproducing with a normal playground file.

tstirrat15 avatar Jan 29 '25 20:01 tstirrat15

Gonna reopen until we get confirmation that it's fixed.

tstirrat15 avatar Jan 29 '25 20:01 tstirrat15

@tstirrat15 yup! Sorry I updated the title to be more clear.

Seems like 0.26.0 fixed it for schemas but adds an extra prefix for relationships

zed import --schema=false --relationships=true schema.zed.yaml
1:14PM ERR terminated with errors error="rpc error: code = FailedPrecondition desc = object definition `studio/studio/permissions` not found"

h3adache avatar Jan 30 '25 18:01 h3adache

🤔 okay, i'll have another look at this today.

tstirrat15 avatar Feb 03 '25 15:02 tstirrat15

Sanity check: was this behavior working in v0.25.0 and v0.26.0 broke it?

tstirrat15 avatar Feb 05 '25 17:02 tstirrat15

The behavior with --schema false seems to be that it will ask the running SpiceDB instance for the schema prefix, and then it prepends it to all of the relationships. Does that match your expectations?

tstirrat15 avatar Feb 06 '25 18:02 tstirrat15