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

fix: nil check for config output #390

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tinygrasshopper
Copy link
Contributor

update-catalog fails with a nil pointer if output is not set

$ go run github.com/snyk/vervet/v8/cmd/[email protected] backstage update-catalog
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x1008ef650]

goroutine 1 [running]:
github.com/snyk/vervet/v8/config.(*Output).ResolvePaths(...)
	/Users/jatin/go/pkg/mod/github.com/snyk/vervet/[email protected]/config/api.go:79
github.com/snyk/vervet/v8/internal/cmd.processCatalog(0x140001c1e80, {0x0, 0x0})
	/Users/jatin/go/pkg/mod/github.com/snyk/vervet/[email protected]/internal/cmd/backstage.go:192 +0x4a0
github.com/snyk/vervet/v8/internal/cmd.UpdateCatalog(0x140001c1e80?)
	/Users/jatin/go/pkg/mod/github.com/snyk/vervet/[email protected]/internal/cmd/backstage.go:75 +0x24
github.com/urfave/cli/v2.(*Command).Run(0x1012c6ae0, 0x140001c1e80, {0x14000306c30, 0x1, 0x1})
	/Users/jatin/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:274 +0x5e0
github.com/urfave/cli/v2.(*Command).Run(0x1012c5e80, 0x140001c1dc0, {0x140001fdc80, 0x2, 0x2})
	/Users/jatin/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:267 +0x81c
github.com/urfave/cli/v2.(*Command).Run(0x14000248420, 0x140001c1c40, {0x1400018c330, 0x3, 0x3})
	/Users/jatin/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:267 +0x81c
github.com/urfave/cli/v2.(*App).RunContext(0x1012c8140, {0x100bced90, 0x140002edad0}, {0x1400018c330, 0x3, 0x3})
	/Users/jatin/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:332 +0x4f8
github.com/snyk/vervet/v8/internal/cmd.(*VervetApp).Run(0x14000181810, {0x1400018c330, 0x3, 0x3})
	/Users/jatin/go/pkg/mod/github.com/snyk/vervet/[email protected]/internal/cmd/cmd.go:51 +0xa0
main.main()
	/Users/jatin/go/pkg/mod/github.com/snyk/vervet/[email protected]/cmd/vervet/main.go:11 +0x3c
exit status 2

@tinygrasshopper tinygrasshopper requested a review from a team as a code owner October 18, 2024 11:20
@tinygrasshopper tinygrasshopper force-pushed the fix/stop-failing-if-output-is-empty branch from 4421f45 to bcc6cbf Compare October 18, 2024 11:36
Copy link
Member

@jgresty jgresty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would output be nil? Surely we should error if that were the case since there would be no api objects written to the catalog info, failing loudly is better than letting teams misconfigure their services

@tinygrasshopper
Copy link
Contributor Author

we explicitly nil check for the output in build, but not in update-catalog
output can be deserialised to nil, if block is not specified
fixing it on the struct, account for other
I agree there is no reason for it to be nil, but the tool should not panic if it is

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