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

nil pointer dereference in Starterproject validation #339

Closed
yangcao77 opened this issue Feb 9, 2021 · 0 comments
Closed

nil pointer dereference in Starterproject validation #339

yangcao77 opened this issue Feb 9, 2021 · 0 comments
Assignees
Labels
area/api Enhancement or issue related to the api/devfile specification kind/bug Something isn't working

Comments

@yangcao77
Copy link
Contributor

I'm seeing this error when I try to validate starterproject in my devfile:

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

goroutine 1 [running]:
github.com/devfile/api/v2/pkg/validation.ValidateStarterProjects(0xc00009b5f0, 0x2, 0x2, 0x0, 0x0)
	/Users/stephanie/go/pkg/mod/github.com/devfile/api/v2@v2.0.0-20210202172954-6424f4139ac7/pkg/validation/projects.go:28 +0x136

It is because the CheckOutFrom is nil, but the code is trying to get the value of CheckOutFrom.Remote

} else if gitSource.CheckoutFrom.Remote != "" {

Need to check if CheckOutFrom != nil before deference it.

Same check should also applys to:

} else if len(gitSource.Remotes) > 1 || gitSource.CheckoutFrom.Remote != "" {
err := validateRemoteMap(gitSource.Remotes, gitSource.CheckoutFrom.Remote, project.Name)

@yangcao77 yangcao77 added area/api Enhancement or issue related to the api/devfile specification kind/bug Something isn't working labels Feb 9, 2021
@yangcao77 yangcao77 self-assigned this Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Enhancement or issue related to the api/devfile specification kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant