astro-cli icon indicating copy to clipboard operation
astro-cli copied to clipboard

environment variable ASTRONOMER_KEY_ID from a non-existing deployment error handling

Open ivica-k opened this issue 1 year ago • 1 comments

Having the environment variable ASTRONOMER_KEY_ID from a deployment that does not exist shows an ugly error when running astro deployment create.

$ astro deployment create --deployment-file dev-deployment.yaml
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/astronomer/astro-cli/cmd/cloud.checkAPIKeys({0x105af9610, 0x14000298170}, {0x105b04b18, 0x140002b71b0}, 0x1)
        github.com/astronomer/astro-cli/cmd/cloud/setup.go:341 +0xc64
github.com/astronomer/astro-cli/cmd/cloud.Setup(0x140001af200, {0x105af9610, 0x14000298170}, {0x105b04b18, 0x140002b71b0})
        github.com/astronomer/astro-cli/cmd/cloud/setup.go:117 +0x508
github.com/astronomer/astro-cli/cmd.NewRootCmd.func1(0x140002afd00?, {0x10557afb2?, 0x4?, 0x10557afb6?})
        github.com/astronomer/astro-cli/cmd/root.go:84 +0x1ec
github.com/spf13/cobra.(*Command).execute(0x140001af200, {0x140004b8de0, 0x3, 0x3})
        github.com/spf13/[email protected]/command.go:891 +0x584
github.com/spf13/cobra.(*Command).ExecuteC(0x14000168900)
        github.com/spf13/[email protected]/command.go:1044 +0x320
github.com/spf13/cobra.(*Command).Execute(0x105af7d78?)
        github.com/spf13/[email protected]/command.go:968 +0x1c
main.main()
        github.com/astronomer/astro-cli/main.go:16 +0x38

What CLI Version did you experience this bug? 1.19.2

This CLI bug is related to which Astronomer Platform?

  • [x] Astro
  • [ ] Software
  • [ ] None/Unknown

What Operating System is the above CLI installed on?

MacOS 13.5.2 (22G91)

🪜 Steps To Reproduce

  1. Create a deployment
  2. Inspect it and save the output to a file astro deployment inspect DEPLOYMENT_ID > deployment.yaml
  3. Generate an API key
  4. Export KEY_ID and SECRET as environment variables
  5. Delete the deployment created in step 1
  6. Using Astro CLI, try to create a new deployment from the template created in step 2. Index out of range and a stacktrace are shown
  7. Unset the KEY_ID and SECRET environment variables unset ASTRONOMER_KEY_ID
  8. Repeat step 6 which should now work

📸 Screenshots

ivica-k avatar Sep 28 '23 16:09 ivica-k

Thanks will be refactoring this command soon. I'll look out for this

sunkickr avatar Oct 12 '23 18:10 sunkickr