astronomer / astro-cli

CLI that makes it easy to create, test and deploy Airflow DAGs to Astronomer
https://www.astronomer.io
Other
341 stars 70 forks source link

DEV - Create env variables when no deployments are present issues panic errors #1592

Closed shri-astro closed 4 months ago

shri-astro commented 4 months ago

In the following section, it's seen that on having no deployments in the workspace, when the env variable related commands are issued, instead of an error message, user sees a panic error

shrividyahegde@Hegde ~ % astro deployment delete -n test

Are you sure you want to delete the test Deployment? (y/n) y

Successfully deleted deployment test
shrividyahegde@Hegde ~ % astro deployment variables create TEST1=SECRET -s 
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x1d8 pc=0x10106afc0]

goroutine 1 [running]:
github.com/astronomer/astro-cli/cloud/deployment.glob..func9({_, _}, {_, _, _, _}, {_, _})
    /go/src/github.com/astronomer/astro-cli/cloud/deployment/deployment.go:1485 +0x140
github.com/astronomer/astro-cli/cloud/deployment.Create({0x0, _}, {_, _}, {_, _}, {_, _}, {_, _}, ...)
    /go/src/github.com/astronomer/astro-cli/cloud/deployment/deployment.go:219 +0x29c
github.com/astronomer/astro-cli/cloud/deployment.deploymentSelectionProcess({_, _}, {_, _, _}, _, {_, _}, {_, _}, ...)
    /go/src/github.com/astronomer/astro-cli/cloud/deployment/deployment.go:1676 +0x2ac
github.com/astronomer/astro-cli/cloud/deployment.GetDeployment({_, _}, {_, _}, {_, _}, _, _, {_, _}, ...)
    /go/src/github.com/astronomer/astro-cli/cloud/deployment/deployment.go:1627 +0x1e0
github.com/astronomer/astro-cli/cloud/deployment.VariableModify({0x0?, 0x0?}, {0x0, 0x0}, {0x0, 0x0}, {0x140005cf5a0?, 0x0?}, {0x1016a6789, 0x4}, ...)
    /go/src/github.com/astronomer/astro-cli/cloud/deployment/deployment_variable.go:94 +0xa8
github.com/astronomer/astro-cli/cmd/cloud.deploymentVariableCreate(0x1400002fb00, {0x14000429340, 0x1, 0x2}, {0x101c42868, 0x14000072028})
    /go/src/github.com/astronomer/astro-cli/cmd/cloud/deployment.go:810 +0x134
github.com/astronomer/astro-cli/cmd/cloud.newDeploymentVariableCreateCmd.func1(0x1400018c800?, {0x14000429340?, 0x4?, 0x1016a68c9?})
    /go/src/github.com/astronomer/astro-cli/cmd/cloud/deployment.go:511 +0x28
github.com/spf13/cobra.(*Command).execute(0x1400002fb00, {0x14000429320, 0x2, 0x2})
    /go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:940 +0x66c
github.com/spf13/cobra.(*Command).ExecuteC(0x140001dc300)
    /go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x320
github.com/spf13/cobra.(*Command).Execute(0x101c5a718?)
    /go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992 +0x1c
main.main()
    /go/src/github.com/astronomer/astro-cli/main.go:21 +0x38
shrividyahegde@Hegde ~ % astro deployment list
no Deployments found in workspace cltirltwn03jc01i21ix5cn6p

What CLI Version did you experience this bug? 1.24.1

This CLI bug is related to which Astronomer Platform?

kushalmalani commented 4 months ago

@shri-astro This has been fixed and will part of the next cli release