Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting ATMOS_CLI_CONFIG_PATH to a file path and not a directory path causes a panic #191

Closed
Gowiem opened this issue Sep 7, 2022 · 4 comments · Fixed by #195
Closed
Assignees
Labels
bug Something isn't working

Comments

@Gowiem
Copy link
Member

Gowiem commented Sep 7, 2022

Describe the Bug

We set ATMOS_CLI_CONFIG_PATH to /mnt/workspace/source/rootfs/usr/local/etc/atmos/atmos.yaml and it resulted in the following:

+ echo 'Writing Stack variables to spacelift.auto.tfvars.json for Spacelift...'
Writing Stack variables to spacelift.auto.tfvars.json for Spacelift...
+ atmos terraform write varfile app --stack=dev -f spacelift.auto.tfvars.json
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x6a455c]

goroutine 1 [running]:
github.com/cloudposse/atmos/pkg/utils.FileExists({0xc0001609b0?, 0x46?})
	/home/runner/work/atmos/atmos/pkg/utils/file_utils.go:25 +0x5c
github.com/cloudposse/atmos/pkg/config.processConfigFile({0xc0001609b0, 0x46}, 0xc00035fc58?)
	/home/runner/work/atmos/atmos/pkg/config/config.go:363 +0x5a
github.com/cloudposse/atmos/pkg/config.InitConfig()
	/home/runner/work/atmos/atmos/pkg/config/config.go:158 +0x495
github.com/cloudposse/atmos/cmd.init.10()
	/home/runner/work/atmos/atmos/cmd/root.go:28 +0x10b
[01GBT2BASCMAXHJQZANQ61C2KF] Unexpected exit code when initializing workspace: 2

Expected Behavior

We would expect a graceful failure instead of a panic.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Set ATMOS_CLI_CONFIG_PATH to a direct path to the atmos.yaml file instead of a directory.
  2. Execute a atmos terraform plan
  3. See error.

Screenshots

N/A

Environment (please complete the following information):

  • Atmos version: v1.4.26

Additional Context

cc @joe-niland

@Gowiem Gowiem added the bug Something isn't working label Sep 7, 2022
@aknysh
Copy link
Member

aknysh commented Sep 7, 2022

@Gowiem thanks.
It's a path to atmos.yaml, should not include the file name

@nitrocode
Copy link
Member

@Gowiem so try changing

export ATMOS_CLI_CONFIG_PATH=/mnt/workspace/source/rootfs/usr/local/etc/atmos/atmos.yaml

to

export ATMOS_CLI_CONFIG_PATH=/mnt/workspace/source/rootfs/usr/local/etc/atmos/

@Gowiem
Copy link
Member Author

Gowiem commented Sep 7, 2022

@aknysh @nitrocode yeah, we figured that out quickly and resolved the problem.

I'm raising this issue because it shouldn't cause a panic and segfault with the above stacktrace -- We should instead get a nice error saying something along the following:

atmos.yaml was not found at the given path: /mnt/workspace/source/rootfs/usr/local/etc/atmos/atmos.yamlatmos.yaml. Please update your ATMOS_CLI_CONFIG_PATH to the correct directory where atmos.yaml can be found

That's all 😄

@aknysh
Copy link
Member

aknysh commented Sep 7, 2022

@aknysh @nitrocode yeah, we figured that out quickly and resolved the problem.

I'm raising this issue because it shouldn't cause a panic and segfault with the above stacktrace -- We should instead get a nice error saying something along the following:

atmos.yaml was not found at the given path: /mnt/workspace/source/rootfs/usr/local/etc/atmos/atmos.yamlatmos.yaml. Please update your ATMOS_CLI_CONFIG_PATH to the correct directory where atmos.yaml can be found

That's all 😄

thank you @Gowiem , we'll improve it

aknysh added a commit that referenced this issue Sep 13, 2022
* fix: updates file_utils#FileExists to check for err (#191)

* chore: adds `atmos.yaml` to error message

Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>

Co-authored-by: Andriy Knysh <aknysh@users.noreply.github.com>
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants