upbound / up

The @upbound CLI
Apache License 2.0
52 stars 41 forks source link

Panic when using Visual Studio extension #131

Closed stevendborrelli closed 2 years ago

stevendborrelli commented 2 years ago

What happened?

Language server crashes with a panic when trying to use against https://github.com/upbound/platform-ref-azure.

How can we reproduce it?

Produces a panic for me:

panic: invalid package type supplied

goroutine 23 [running]:
github.com/upbound/up/internal/xpls/server.(*Server).Initialize(0x140003658c0, 0x102986878, 0x140001a2008, 0x140001715f0, 0x0, 0x0, 0x0, 0xc00, 0x140001fc400)
    /home/runner/work/up/up/internal/xpls/server/server.go:124 +0x2e8
github.com/upbound/up/internal/xpls/dispatcher.(*Dispatcher).Dispatch(0x1400044b970, 0x102986878, 0x140001a2008, 0x1029919b8, 0x140003658c0, 0x140001715f0, 0x140004fce60)
    /home/runner/work/up/up/internal/xpls/dispatcher/dispatcher.go:80 +0x124
github.com/upbound/up/internal/xpls/handler.(*Handler).Handle(0x14000492be0, 0x102986878, 0x140001a2008, 0x140001715f0, 0x140004fce60)
    /home/runner/work/up/up/internal/xpls/handler/handler.go:69 +0x60
github.com/sourcegraph/jsonrpc2.(*Conn).readMessages(0x140001715f0, 0x102986878, 0x140001a2008)
    /home/runner/work/up/up/vendor/github.com/sourcegraph/jsonrpc2/jsonrpc2.go:553 +0x4dc
created by github.com/sourcegraph/jsonrpc2.NewConn
    /home/runner/work/up/up/vendor/github.com/sourcegraph/jsonrpc2/jsonrpc2.go:334 +0x198
stevendborrelli commented 2 years ago

This may be related to Configuration packages now being v1 instead of v1alpha1 https://doc.crds.dev/github.com/crossplane/crossplane/pkg.crossplane.io/Configuration/v1@v1.6.1.

tnthornton commented 2 years ago

This may be related to Configuration packages now being v1 instead of v1alpha1 https://doc.crds.dev/github.com/crossplane/crossplane/pkg.crossplane.io/Configuration/v1@v1.6.1.

@stevendborrelli your suspicion around v1 vs v1alpha1 seems to be spot on. If I switch the apiVersion in the crossplane.yaml to apiVersion: meta.pkg.crossplane.io/v1 and reload the IDE, the panic goes away.

tnthornton commented 2 years ago

It looks like we're hitting the error here https://github.com/upbound/up/blob/main/internal/xpkg/workspace/meta/meta.go#L52-L56

I'm thinking the fix for this is: