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

Panic occurs while validating OpenAPI response #912

Closed
h6ah4i opened this issue May 5, 2024 · 1 comment · Fixed by #914
Closed

Panic occurs while validating OpenAPI response #912

h6ah4i opened this issue May 5, 2024 · 1 comment · Fixed by #914
Assignees
Labels
bug Something isn't working

Comments

@h6ah4i
Copy link
Contributor

h6ah4i commented May 5, 2024

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 k1LoW added the bug Something isn't working label May 5, 2024
@k1LoW k1LoW self-assigned this May 5, 2024
@k1LoW
Copy link
Owner

k1LoW commented May 5, 2024

@h6ah4i Thank you for your report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants