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

Remove nil possibility #95

Merged
merged 1 commit into from
Jan 4, 2024
Merged

Remove nil possibility #95

merged 1 commit into from
Jan 4, 2024

Conversation

notanthony
Copy link
Contributor

@notanthony notanthony commented Jan 4, 2024

There exists a case where cmdContext() returns an error. This would result in viper.Viper being nil and handle errors breaks.

`panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1454ae9]

goroutine 1 [running]:
github.com/spf13/viper.(*Viper).find(0x0, {0x18711e6, 0x6}, 0x1)
	/Users/runner/work/cone/cone/vendor/github.com/spf13/viper/viper.go:1236 +0x49
github.com/spf13/viper.(*Viper).Get(0x0, {0x18711e6?, 0x1f15e60?})
	/Users/runner/work/cone/cone/vendor/github.com/spf13/viper/viper.go:892 +0x4f
github.com/spf13/viper.(*Viper).GetString(0x16bf66e?, {0x18711e6?, 0x187754a?})
	/Users/runner/work/cone/cone/vendor/github.com/spf13/viper/viper.go:959 +0x1e
github.com/conductorone/cone/pkg/client.HandleErrors({0x1989fd8, 0xc0000ae050}, 0x1?, {0x1982f40, 0xc00009e110})
	/Users/runner/work/cone/cone/pkg/client/error.go:53 +0x5a
main.runCli({0x1989fd8?, 0xc0000ae050})
	/Users/runner/work/cone/cone/cmd/cone/main.go:77 +0x60d
main.main()
	/Users/runner/work/cone/cone/cmd/cone/main.go:31 +0x105`

@notanthony notanthony merged commit e737c87 into main Jan 4, 2024
2 checks passed
@notanthony notanthony deleted the anthony/fix-nil-error branch January 4, 2024 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants