Skip to content

lint_rego.go throws error when rule returns empty errors array #107

@bartzantingh

Description

@bartzantingh

The following error is thrown when a rego rule returns an empty array of errors, resulting in the linting process to fail and errors in the report:

panic: interface conversion: interface {} is nil, not []interface {}

It seems this is caused by an unsafe evaluation of the errors array on line 75 in lint_rego.go:

errors := rsmap["errors"].([]interface{})

which could supposedly be fixed by adding an explicit check for an empty array:

errors, ok := rsmap["errors"].([]interface{})
if !ok || errors == nil {
    errors = []interface{}{}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions