k1LoW / runn

runn is a package/tool for running operations following a scenario.
https://runn.run
MIT License
417 stars 30 forks source link

Panic occurs while validating OpenAPI response #912

Closed h6ah4i closed 4 months ago

h6ah4i commented 4 months ago

Hi. I found a runn panic() issue that occurs in certain situation.

Situation

  1. The OpenAPI schema uses range of status codes (e.g. 4XX, 5XX, ...)
  2. Returns a response with not declared content-type in OpenAPI schema

Repro test case

Stack trace

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

goroutine 16208 [running]:
github.com/pb33f/libopenapi-validator/errors.ResponseContentTypeNotFound(0xc001795ba0, 0xc0039e30e0, 0xc003bc9920?, {0xc003d6e390, 0x3}, 0x0)
    /go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.51/errors/response_errors.go:30 +0xe9
github.com/pb33f/libopenapi-validator/responses.(*responseBodyValidator).ValidateResponseBody(0xc0022a9280, 0xc0039e30e0, 0xc003d79ef0)
    /go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.51/responses/validate_body.go:70 +0x3eb
github.com/pb33f/libopenapi-validator.(*validator).ValidateHttpResponse(0xc002cd3c00, 0xc0039e30e0, 0xc003d79ef0)
    /go/pkg/mod/github.com/pb33f/libopenapi-validator@v0.0.51/validator.go:116 +0xc5
github.com/k1LoW/runn.(*openAPI3Validator).ValidateResponse(0xc00104c150, {0xc0039e30e0?, 0xc00398b580?}, 0xc0039e30e0, 0xc003d79ef0)
    /workdir/http_validator.go:217 +0x99
github.com/k1LoW/runn.(*httpRunner).run(0xc001b98e40, {0x2687040, 0xc0032711d0}, 0xc003d8e900, 0xc001eb3040)
    /workdir/http.go:515 +0xeaf
github.com/k1LoW/runn.(*httpRunner).Run(0xc001b98e40, {0x2687040, 0xc0032711d0}, 0xc001eb3040)
    /workdir/http.go:377 +0x92
github.com/k1LoW/runn.(*operator).runStep.func1(0x2234f80?)
    /workdir/operator.go:185 +0xe5
github.com/k1LoW/runn.(*operator).runStep(0xc001764fc8, {0x2687040, 0xc0032711d0}, 0x3, 0xc001eb3040)
    /workdir/operator.go:290 +0xda8
github.com/k1LoW/runn.(*operator).runInternal(0xc001764fc8, {0x2687040, 0xc0032711d0})
    /workdir/operator.go:1110 +0x668
github.com/k1LoW/runn.(*operator).run(0xc001764fc8, {0x2687040, 0xc0032711d0})
    /workdir/operator.go:935 +0x247
github.com/k1LoW/runn.(*operators).runN.func1()
    /workdir/operator.go:1567 +0x21e
github.com/k1LoW/concgroup.(*Group).GoMulti.func1()
    /go/pkg/mod/github.com/k1!lo!w/concgroup@v1.1.0/concgroup.go:62 +0xeb
golang.org/x/sync/errgroup.(*Group).Go.func1()
    /go/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup.go:78 +0x56
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
    /go/pkg/mod/golang.org/x/sync@v0.7.0/errgroup/errgroup.go:75 +0x9
k1LoW commented 4 months ago

@h6ah4i Thank you for your report!