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

There is a panic when invalid schema of route/operation is used in spec generation. It should prevent it #1791

Merged
merged 2 commits into from
Nov 15, 2018

Conversation

marsianin
Copy link
Contributor

When run

swagger generate spec -o swagger.json

i got follow issue

Rinats-MacBook-Pro:gomoona rinat$
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x118 pc=0x1603e4a]

goroutine 1 [running]:
github.com/go-swagger/go-swagger/scan.(*setOpParams).Parse(0xc42e2476e0, 0xc423b9fb00, 0x5, 0x8, 0xc423b9fb00, 0x0)
	/Users/rinat/dev/go/src/github.com/go-swagger/go-swagger/scan/route_params.go:109 +0x29a
github.com/go-swagger/go-swagger/scan.(*tagParser).Parse(0xc4205cf310, 0xc423b9fb00, 0x5, 0x8, 0x0, 0xc423b9fb00)
	/Users/rinat/dev/go/src/github.com/go-swagger/go-swagger/scan/scanner.go:558 +0x52
github.com/go-swagger/go-swagger/scan.(*sectionedParser).Parse(0xc4205cf9f0, 0xc42e247340, 0xc4205cf620, 0xd)
	/Users/rinat/dev/go/src/github.com/go-swagger/go-swagger/scan/scanner.go:944 +0x7f4
github.com/go-swagger/go-swagger/scan.(*routesParser).Parse(0xc43bf5a5c0, 0xc4207fcf80, 0x16fe000, 0xc4277248d0, 0xc42c913d70, 0xc42c913da0, 0x0, 0x0)
	/Users/rinat/dev/go/src/github.com/go-swagger/go-swagger/scan/routes.go:110 +0xc55
github.com/go-swagger/go-swagger/scan.(*appScanner).parseRoutes(0xc4304e0d00, 0xc4207fcf80, 0x0, 0x0)
	/Users/rinat/dev/go/src/github.com/go-swagger/go-swagger/scan/scanner.go:423 +0xea
github.com/go-swagger/go-swagger/scan.(*appScanner).Parse(0xc4304e0d00, 0xc4304e0d00, 0x0, 0x0)
	/Users/rinat/dev/go/src/github.com/go-swagger/go-swagger/scan/scanner.go:351 +0x27b
github.com/go-swagger/go-swagger/scan.Application(0x16c6e1c, 0x1, 0x0, 0x0, 0x16a230f, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/rinat/dev/go/src/github.com/go-swagger/go-swagger/scan/scanner.go:186 +0x72
github.com/go-swagger/go-swagger/cmd/swagger/commands/generate.(*SpecFile).Execute(0xc420246160, 0xc4200b7f80, 0x0, 0x4, 0xc420246160, 0x1)
	/Users/rinat/dev/go/src/github.com/go-swagger/go-swagger/cmd/swagger/commands/generate/spec.go:61 +0x196
github.com/go-swagger/go-swagger/vendor/github.com/jessevdk/go-flags.(*Parser).ParseArgs(0xc420133b00, 0xc4200c0100, 0x4, 0x4, 0x1012518, 0x30, 0xc4200c4900, 0xc420475b00, 0xc420357800)
	/Users/rinat/dev/go/src/github.com/go-swagger/go-swagger/vendor/github.com/jessevdk/go-flags/parser.go:316 +0x80b
github.com/go-swagger/go-swagger/vendor/github.com/jessevdk/go-flags.(*Parser).Parse(0xc420133b00, 0x6, 0x179d2fe, 0x6, 0x0, 0x17e8067)
	/Users/rinat/dev/go/src/github.com/go-swagger/go-swagger/vendor/github.com/jessevdk/go-flags/parser.go:186 +0x71

and now:

swagger generate spec -o swagger.json
operation (nightSettings): invalid route schema provided

It was faced by mistaken misprint "swagger:route" when need to use "swagger:operation"

@casualjim
Copy link
Member

…ce" when invalid signature for route provided

Signed-off-by: rinat <marsianin86@gmail.com>
…ce" when invalid signature for route provided + gofmt

Signed-off-by: rinat <marsianin86@gmail.com>
@codecov
Copy link

codecov bot commented Nov 9, 2018

Codecov Report

Merging #1791 into master will decrease coverage by 0.02%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1791      +/-   ##
==========================================
- Coverage   80.04%   80.02%   -0.03%     
==========================================
  Files          38       38              
  Lines        7497     7499       +2     
==========================================
  Hits         6001     6001              
- Misses       1019     1020       +1     
- Partials      477      478       +1
Impacted Files Coverage Δ
scan/route_params.go 95.08% <0%> (-1.59%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 800a305...5e5e181. Read the comment docs.

@casualjim casualjim merged commit df84521 into go-swagger:master Nov 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants