Skip to content

Error with contain-substring/mach-regexp matcher and json/junit formatters  #846

@loliee

Description

@loliee

Describe the bug

I try to use the contain-substring matcher with the junit, json formatters but I have the following error: panic: interface conversion: interface {} is nil, not float64.

How To Reproduce

# goss/datadog.yml
package:
  datadog-agent:
     installed: true
     versions:
       and:
         - have-len: 1
         - contain-substring: "7.1"

And validate it with junit formatter :

goss -g goss/datadog.yml validate -f junit

ℹ️ I also had the same issues with ip ressource.

Expected Behavior

Finishing without errors like with the documentation or rspecish formatters.

Actual Behavior

goss -g goss/datadog.yml validate -f documentation
Package: datadog-agent: installed: matches expectation: true
Package: datadog-agent: version: matches expectation: {"and":[{"have-len":1},{"contain-substring":"7.1"}]}

💥

goss -g goss/datadog.yml validate -f junit
panic: interface conversion: interface {} is nil, not float64

goroutine 1 [running]:
github.com/goss-org/goss/outputs.JUnit.Output({}, {0xc86920, 0xc000012018}, 0xc0000463c0?, {{0x11ba608?, 0xc0001c0a40?, 0xc000282400?}})
        /home/travis/gopath/src/github.com/goss-org/goss/outputs/junit.go:51 +0xe8c
github.com/goss-org/goss.ValidateConfig(0xc0001c6200, 0xc000282280)
        /home/travis/gopath/src/github.com/goss-org/goss/validate.go:142 +0x42a
github.com/goss-org/goss.Validate(0xc0001c6200)
        /home/travis/gopath/src/github.com/goss-org/goss/validate.go:111 +0x85
main.main.func1(0xc00010b1e0?)
        /home/travis/gopath/src/github.com/goss-org/goss/cmd/goss/goss.go:151 +0x25
github.com/urfave/cli.HandleAction({0xaaa1a0?, 0xbddc50?}, 0x8?)
        /home/travis/gopath/pkg/mod/github.com/urfave/cli@v1.22.14/app.go:524 +0x50
github.com/urfave/cli.Command.Run({{0xb8f1c5, 0x8}, {0x0, 0x0}, {0xc000191b20, 0x1, 0x1}, {0xb95bee, 0xf}, {0x0, ...}, ...}, ...)
        /home/travis/gopath/pkg/mod/github.com/urfave/cli@v1.22.14/command.go:175 +0x67b
github.com/urfave/cli.(*App).Run(0xc000164e00, {0xc0000341e0, 0x6, 0x6})
        /home/travis/gopath/pkg/mod/github.com/urfave/cli@v1.22.14/app.go:277 +0xb87
main.main()
        /home/travis/gopath/src/github.com/goss-org/goss/cmd/goss/goss.go:408 +0x2078
junit

Environment:

  • Version of goss: v0.4.2
  • OS/Distribution version: Linux (Debian 11)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions