Skip to content

nil pointer dereference in Starterproject validation #339

Closed
@yangcao77

Description

@yangcao77

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/[email protected]/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)

Metadata

Metadata

Assignees

Labels

area/apiEnhancement or issue related to the api/devfile specificationkind/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions