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: interface conversion: interface {} is nil, not string #47

Closed
bhechinger opened this issue Nov 27, 2017 · 5 comments
Closed

panic: interface conversion: interface {} is nil, not string #47

bhechinger opened this issue Nov 27, 2017 · 5 comments

Comments

@bhechinger
Copy link

I'm fetching this swagger spec file: https://esi.tech.ccp.is/latest/swagger.json?datasource=tranquility

When I run openapi2proto against it I get an error (and massive stacktrace). Not sure what's going on as that's not completely descriptive to me.

11:24 $ openapi2proto -spec esi.yaml
panic: interface conversion: interface {} is nil, not string [recovered]
	panic: interface conversion: interface {} is nil, not string [recovered]
	panic: interface conversion: interface {} is nil, not string

goroutine 1 [running]:
text/template.errRecover(0xc420095ce8)
	/usr/lib/go-1.8/src/text/template/exec.go:140 +0x1ec
panic(0x72a7c0, 0xc420307dc0)
	/usr/lib/go-1.8/src/runtime/panic.go:489 +0x2cf
text/template.errRecover(0xc4200949d8)
	/usr/lib/go-1.8/src/text/template/exec.go:140 +0x1ec
panic(0x72a7c0, 0xc420307dc0)
	/usr/lib/go-1.8/src/runtime/panic.go:489 +0x2cf
github.com/NYTimes/openapi2proto.(*Items).ProtoMessage(0xc42024a000, 0xc4202cf890, 0x30, 0xc420242a40, 0x8, 0xc420406180, 0xc42028c5f0, 0x0, 0x0, 0x0)
	/home/wonko/go/src/github.com/NYTimes/openapi2proto/openapi.go:249 +0x12b9
reflect.Value.call(0x7379e0, 0xc42024a000, 0xa13, 0x77ddae, 0x4, 0xc4204cb800, 0x5, 0x5, 0xc400009514, 0x6e2514, ...)
	/usr/lib/go-1.8/src/reflect/value.go:434 +0x91f
reflect.Value.Call(0x7379e0, 0xc42024a000, 0xa13, 0xc4204cb800, 0x5, 0x5, 0x8e48a0, 0xc420011b30, 0x70c480)
	/usr/lib/go-1.8/src/reflect/value.go:302 +0xa4
text/template.(*state).evalCall(0xc420094958, 0x7379e0, 0xc42024a000, 0x16, 0x7379e0, 0xc42024a000, 0xa13, 0x8e48a0, 0xc42013ab70, 0xc42013c1e6, ...)
	/usr/lib/go-1.8/src/text/template/exec.go:668 +0x51f
text/template.(*state).evalField(0xc420094958, 0x7379e0, 0xc42024a000, 0x16, 0xc42013c1e6, 0xc, 0x8e48a0, 0xc42013ab70, 0xc42006a580, 0x6, ...)
	/usr/lib/go-1.8/src/text/template/exec.go:558 +0xe18
text/template.(*state).evalFieldChain(0xc420094958, 0x7379e0, 0xc42024a000, 0x16, 0x7379e0, 0xc42024a000, 0x16, 0x8e48a0, 0xc42013ab70, 0xc42013c210, ...)
	/usr/lib/go-1.8/src/text/template/exec.go:526 +0x22b
text/template.(*state).evalVariableNode(0xc420094958, 0x7379e0, 0xc42024a000, 0x16, 0xc42013ab70, 0xc42006a580, 0x6, 0x8, 0x0, 0x0, ...)
	/usr/lib/go-1.8/src/text/template/exec.go:514 +0x1ac
text/template.(*state).evalCommand(0xc420094958, 0x7379e0, 0xc42024a000, 0x16, 0xc42013ab10, 0x0, 0x0, 0x0, 0xc4200944b0, 0xc420094538, ...)
	/usr/lib/go-1.8/src/text/template/exec.go:438 +0x900
text/template.(*state).evalPipeline(0xc420094958, 0x7379e0, 0xc42024a000, 0x16, 0xc4201403c0, 0x0, 0x0, 0x0)
	/usr/lib/go-1.8/src/text/template/exec.go:406 +0xf2
text/template.(*state).walk(0xc420094958, 0x7379e0, 0xc42024a000, 0x16, 0x8e42a0, 0xc420011b60)
	/usr/lib/go-1.8/src/text/template/exec.go:232 +0x55a
text/template.(*state).walk(0xc420094958, 0x7379e0, 0xc42024a000, 0x16, 0x8e45a0, 0xc420011830)
	/usr/lib/go-1.8/src/text/template/exec.go:240 +0x139
text/template.(*state).walkRange.func1(0x70ccc0, 0xc42028ca10, 0x98, 0x7379e0, 0xc42024a000, 0x16)
	/usr/lib/go-1.8/src/text/template/exec.go:327 +0x136
text/template.(*state).walkRange(0xc420094958, 0x744740, 0xc42028c5d0, 0x99, 0xc420018740)
	/usr/lib/go-1.8/src/text/template/exec.go:344 +0x5a2
text/template.(*state).walk(0xc420094958, 0x744740, 0xc42028c5d0, 0x99, 0x8e4720, 0xc420018740)
	/usr/lib/go-1.8/src/text/template/exec.go:243 +0x4f1
text/template.(*state).walk(0xc420094958, 0x744740, 0xc42028c5d0, 0x99, 0x8e45a0, 0xc420144720)
	/usr/lib/go-1.8/src/text/template/exec.go:240 +0x139
text/template.(*Template).execute(0xc4201561c0, 0x8deac0, 0xc42020f570, 0x744740, 0xc42028c5d0, 0x0, 0x0)
	/usr/lib/go-1.8/src/text/template/exec.go:195 +0x20a
text/template.(*Template).Execute(0xc4201561c0, 0x8deac0, 0xc42020f570, 0x744740, 0xc42028c5d0, 0xc4202cf890, 0x30)
	/usr/lib/go-1.8/src/text/template/exec.go:178 +0x53
github.com/NYTimes/openapi2proto.Parameters.ProtoMessage(0xc420140730, 0x7, 0x9, 0x0, 0x0, 0x0, 0xc4202cf800, 0x29, 0xc420406180, 0x6cf4ef, ...)
	/home/wonko/go/src/github.com/NYTimes/openapi2proto/openapi.go:699 +0x1fc
github.com/NYTimes/openapi2proto.(*Endpoint).protoMessages(0xc42015c7e0, 0x0, 0x0, 0x0, 0xc4202cf800, 0x29, 0xc420406180, 0xc420228600, 0x5a7)
	/home/wonko/go/src/github.com/NYTimes/openapi2proto/openapi.go:573 +0xc1
github.com/NYTimes/openapi2proto.(*Path).ProtoMessages(0xc42013f3c0, 0xc420240d80, 0x2f, 0xc420406180, 0x0, 0x0)
	/home/wonko/go/src/github.com/NYTimes/openapi2proto/openapi.go:631 +0x375
reflect.Value.call(0x7298c0, 0xc42013f3c0, 0x613, 0x77ddae, 0x4, 0xc4202ce150, 0x2, 0x2, 0xc40000d8f0, 0x6e68f0, ...)
	/usr/lib/go-1.8/src/reflect/value.go:434 +0x91f
reflect.Value.Call(0x7298c0, 0xc42013f3c0, 0x613, 0xc4202ce150, 0x2, 0x2, 0x8e48a0, 0xc420144360, 0x7266c0)
	/usr/lib/go-1.8/src/reflect/value.go:302 +0xa4
text/template.(*state).evalCall(0xc420095c68, 0x7298c0, 0xc42013f3c0, 0x16, 0x7298c0, 0xc42013f3c0, 0x613, 0x8e48a0, 0xc420144300, 0xc42015404a, ...)
	/usr/lib/go-1.8/src/text/template/exec.go:668 +0x51f
text/template.(*state).evalField(0xc420095c68, 0x7298c0, 0xc42013f3c0, 0x16, 0xc42015404a, 0xd, 0x8e48a0, 0xc420144300, 0xc420156080, 0x3, ...)
	/usr/lib/go-1.8/src/text/template/exec.go:558 +0xe18
text/template.(*state).evalFieldChain(0xc420095c68, 0x7298c0, 0xc42013f3c0, 0x16, 0x7298c0, 0xc42013f3c0, 0x16, 0x8e48a0, 0xc420144300, 0xc420154070, ...)
	/usr/lib/go-1.8/src/text/template/exec.go:526 +0x22b
text/template.(*state).evalVariableNode(0xc420095c68, 0x7298c0, 0xc42013f3c0, 0x16, 0xc420144300, 0xc420156080, 0x3, 0x4, 0x0, 0x0, ...)
	/usr/lib/go-1.8/src/text/template/exec.go:514 +0x1ac
text/template.(*state).evalCommand(0xc420095c68, 0x7298c0, 0xc42013f3c0, 0x16, 0xc4201442a0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/usr/lib/go-1.8/src/text/template/exec.go:438 +0x900
text/template.(*state).evalPipeline(0xc420095c68, 0x7298c0, 0xc42013f3c0, 0x16, 0xc4201420a0, 0x0, 0x0, 0xc4200958c8)
	/usr/lib/go-1.8/src/text/template/exec.go:406 +0xf2
text/template.(*state).walk(0xc420095c68, 0x7298c0, 0xc42013f3c0, 0x16, 0x8e42a0, 0xc420144390)
	/usr/lib/go-1.8/src/text/template/exec.go:232 +0x55a
text/template.(*state).walk(0xc420095c68, 0x7298c0, 0xc42013f3c0, 0x16, 0x8e45a0, 0xc420144240)
	/usr/lib/go-1.8/src/text/template/exec.go:240 +0x139
text/template.(*state).walkRange.func1(0x70ccc0, 0xc420136a40, 0x98, 0x7298c0, 0xc42013f3c0, 0x16)
	/usr/lib/go-1.8/src/text/template/exec.go:327 +0x136
text/template.(*state).walkRange(0xc420093c68, 0x742440, 0xc42026ad50, 0x99, 0xc420156100)
	/usr/lib/go-1.8/src/text/template/exec.go:344 +0x5a2
text/template.(*state).walk(0xc420093c68, 0x742440, 0xc42026ad50, 0x99, 0x8e4720, 0xc420156100)
	/usr/lib/go-1.8/src/text/template/exec.go:243 +0x4f1
text/template.(*state).walk(0xc420095c68, 0x742440, 0xc42026ad50, 0x99, 0x8e45a0, 0xc420011500)
	/usr/lib/go-1.8/src/text/template/exec.go:240 +0x139
text/template.(*Template).execute(0xc4200185c0, 0x8deac0, 0xc42020e230, 0x742440, 0xc42026ad50, 0x0, 0x0)
	/usr/lib/go-1.8/src/text/template/exec.go:195 +0x20a
text/template.(*Template).Execute(0xc4200185c0, 0x8deac0, 0xc42020e230, 0x742440, 0xc42026ad50, 0x0, 0xc420136470)
	/usr/lib/go-1.8/src/text/template/exec.go:178 +0x53
github.com/NYTimes/openapi2proto.GenerateProto(0xc42020a000, 0x0, 0xc42020a000, 0x0, 0x0, 0xc420136428, 0xc420136470)
	/home/wonko/go/src/github.com/NYTimes/openapi2proto/proto.go:171 +0x307
main.main()
	/home/wonko/go/src/github.com/NYTimes/openapi2proto/cmd/openapi2proto/main.go:21 +0x1e1
@bhechinger
Copy link
Author

bhechinger commented Nov 27, 2017

Update, if I load the swagger spec (JSON) into SwaggerHub and then download it as a Resolved YAML file I hit #40 so I wonder if it isn't somehow related to that.

If I download it as an Unresolved YAML file I get this same error here.

@jprobinson
Copy link
Contributor

Howdy @bhechinger!

I've just pushed a commit to master that provides a much cleaner error message. From running this spec through the tool, it seems you're missing a type field on one of your nested schema definitions:

encountered a non-string schema 'type' value within "PutCharactersCharacter_idCalendarEvent_idRequest", which is not supported by this tool. Field: "response", Type: <nil>%

I'm looking through the spec and this field may not be required if the field is "in": "body" so I'm going to see if I can handle that properly for you.

Stay tuned!

@bhechinger
Copy link
Author

It's not my spec but if you think I should badger the authors about that (if it's actually wrong) then I certainly will. :)

@bhechinger
Copy link
Author

Woo! That fixed it, thanks man!!

@jprobinson
Copy link
Contributor

No problem! I think I introduced this bug with some other recent updates, so felt obligated to knock it out.

Please holler if you run into any other funk!

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

No branches or pull requests

2 participants