macaron
macaron copied to clipboard
PANIC: reflect: call of reflect.Value.Interface on zero Value
[Macaron] PANIC: reflect: call of reflect.Value.Interface on zero Value
/usr/local/go/src/runtime/panic.go:426 (0x8070a0d)
gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))
/usr/local/go/src/reflect/value.go:913 (0x81a05fa)
valueInterface: panic(&ValueError{"reflect.Value.Interface", 0})
/usr/local/go/src/reflect/value.go:908 (0x81a0572)
Value.Interface: return valueInterface(v, true)
/home/simon/go/src/github.com/go-macaron/binding/binding.go:333 (0x825ec6b)
validateField: sliceValue := sliceVal.Interface()
/home/simon/go/src/github.com/go-macaron/binding/binding.go:320 (0x825e9fe)
validateStruct: errors = validateField(errors, zero, field, fieldVal, fieldValue)
/home/simon/go/src/github.com/go-macaron/binding/binding.go:318 (0x825e95a)
validateStruct: errors = validateStruct(errors, fieldValue)
/home/simon/go/src/github.com/go-macaron/binding/binding.go:236 (0x8264d23)
Validate.func1: errors = validateStruct(errors, obj)
/usr/local/go/src/runtime/asm_386.s:488 (0x80973da)
call16: CALLFN(·call16, 16)
/usr/local/go/src/reflect/value.go:435 (0x819ecdb)
Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
/usr/local/go/src/reflect/value.go:303 (0x819dcfc)
Value.Call: return v.call("Call", in)
/home/simon/go/src/github.com/go-macaron/inject/inject.go:117 (0x81b7fd4)
(*injector).Invoke: return reflect.ValueOf(f).Call(in), nil
/home/simon/go/src/github.com/go-macaron/binding/binding.go:633 (0x8263e61)
validateAndMap: ctx.Invoke(Validate(obj.Interface()))
/home/simon/go/src/github.com/go-macaron/binding/binding.go:210 (0x82649ed)
Json.func1: validateAndMap(jsonStruct, ctx, errors, ifacePtr...)
/usr/local/go/src/runtime/asm_386.s:488 (0x80973da)
call16: CALLFN(·call16, 16)
/usr/local/go/src/reflect/value.go:435 (0x819ecdb)
Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
/usr/local/go/src/reflect/value.go:303 (0x819dcfc)
Value.Call: return v.call("Call", in)
/home/simon/go/src/github.com/go-macaron/inject/inject.go:117 (0x81b7fd4)
(*injector).Invoke: return reflect.ValueOf(f).Call(in), nil
/home/simon/go/src/gopkg.in/macaron.v1/context.go:113 (0x809bd54)
(*Context).run: vals, err := c.Invoke(c.handler())
/home/simon/go/src/gopkg.in/macaron.v1/context.go:104 (0x809bc68)
(*Context).Next: c.run()
/home/simon/go/src/gopkg.in/macaron.v1/recovery.go:161 (0x80ada5b)
Recovery.func1: c.Next()
/usr/local/go/src/runtime/asm_386.s:488 (0x80973da)
call16: CALLFN(·call16, 16)
/usr/local/go/src/reflect/value.go:435 (0x819ecdb)
Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
/usr/local/go/src/reflect/value.go:303 (0x819dcfc)
Value.Call: return v.call("Call", in)
/home/simon/go/src/github.com/go-macaron/inject/inject.go:117 (0x81b7fd4)
(*injector).Invoke: return reflect.ValueOf(f).Call(in), nil
/home/simon/go/src/gopkg.in/macaron.v1/context.go:113 (0x809bd54)
(*Context).run: vals, err := c.Invoke(c.handler())
/home/simon/go/src/gopkg.in/macaron.v1/context.go:104 (0x809bc68)
(*Context).Next: c.run()
/home/simon/go/src/gopkg.in/macaron.v1/logger.go:40 (0x80aca1e)
Logger.func1: ctx.Next()
/usr/local/go/src/runtime/asm_386.s:488 (0x80973da)
call16: CALLFN(·call16, 16)
/usr/local/go/src/reflect/value.go:435 (0x819ecdb)
Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
/usr/local/go/src/reflect/value.go:303 (0x819dcfc)
Value.Call: return v.call("Call", in)
/home/simon/go/src/github.com/go-macaron/inject/inject.go:117 (0x81b7fd4)
(*injector).Invoke: return reflect.ValueOf(f).Call(in), nil
/home/simon/go/src/gopkg.in/macaron.v1/context.go:113 (0x809bd54)
(*Context).run: vals, err := c.Invoke(c.handler())
/home/simon/go/src/gopkg.in/macaron.v1/router.go:184 (0x80aef02)
(*Router).Handle.func1: c.run()
/home/simon/go/src/gopkg.in/macaron.v1/router.go:286 (0x80a75bd)
(*Router).ServeHTTP: h(rw, req, p)
/home/simon/go/src/gopkg.in/macaron.v1/macaron.go:177 (0x80a041f)
(*Macaron).ServeHTTP: m.Router.ServeHTTP(rw, req)
/usr/local/go/src/net/http/server.go:2081 (0x816a256)
serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/local/go/src/net/http/server.go:1472 (0x81676a8)
(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/local/go/src/runtime/asm_386.s:1585 (0x8099211)
goexit: BYTE $0x90 // NOP
Please dump your code here.
URL:
[Macaron] Started POST /api/messages/draft for 127.0.0.1
...
[Macaron] Completed /api/messages/draft 500 Internal Server Error in 104.254249ms
Code:
- Handler: https://github.com/emersion/neutron/blob/master/router/api/messages.go#L284
- Route: https://github.com/emersion/neutron/blob/master/router/api/api.go#L162
Request:
POST /api/messages/draft HTTP/1.1
Host: localhost:4000
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:45.0) Gecko/20100101 Firefox/45.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
x-pm-appversion: Web_3.1.4
x-pm-apiversion: 1
x-pm-session: access_token
Content-Type: application/json;charset=utf-8
Referer: http://localhost:4000/inbox/conversation_id
Content-Length: 1207
Cookie: AUTH-session_token=%7B%22AccessToken%22%3A%22access_token%22%2C%22UID%22%3A%22uid%22%7D; AUTH-access_token=%7B%22AccessToken%22%3A%22access_token%22%2C%22UID%22%3A%22user_id%22%7D; _ga=GA1.1.121585592.1457627255
Connection: keep-alive
{"Message":{"ToList":[null],"CCList":[],"BCCList":[],"Subject":"Re: Hello World","IsRead":1,"AddressID":"address_id","Body":"-----BEGIN PGP MESSAGE-----\r\nVersion: OpenPGP.js v1.2.0\r\nComment: http://openpgpjs.org\r\n\r\nwcBMA62isfAUsO8vAQf/Wh8BisnhnsJ2LvnvlMSaIVhRvp+CUNxj3uA3eU4n\nYFITLHrYALtyVLI40IWcKRSgGihA+umwrB3uuzxuPqhE4dZAYDvszHgrJk65\niCFu97E+4cvkQH3FpCTnyeimc/4bJIsnJKU7KhJg/wMy9TJIHJiDG4lgC6bT\nJJ29GEFqve8tmim8pfw5gJ4lAVwWxPL0SpXwdqabwMKlN0xAHHPY/QEwVkvy\n29g8+Vn64vTedicG+kIdVm0BiNwPvM1w1RelUOCekHpDZPrNUd93GFDvm+4H\nuZy/Pvaovv7rwV9+38ZA8LsSKJPyYI7xL/eU6iBbXtXpVevZGATZPcLv6S85\nFtLAhgHImWBmwiIX7NRyXZghMDgjdM89EQvXJh/jwVfF0HsBwrf31G9WdBX7\nAgO5teiw57lhbao3IJzSg5TdKFvwy5wFnPkqB/3u24w5fLVCdu3FNHPu4MB7\nGRtzwTwlJ/FtJM4B5Vgup1xT91VsU2g4/K5SvVYi0nG1r9dBb9U1l5cCYHlq\nOCljYFrT3JXc45eyov2k4ser2BEX2jc+MpbcLpEHk7QGkMg6Ey4ialmfZgCC\ny9SpAPI1hIWnYaXh2hBWAkxDEhRk4r43zODsF4YugOWTA7Tt95M2x7P4hzdT\nC5moDFnLDfZhKBcymdqlxh+pUMFjChV5x1BP9/55G3bRaUV7FUvj3TYA6NfR\nLgSqre6EOyvh06+e/cjNAQ/yRVSaSUGTpDXPF+uvb9Zj9rA+ZyR/WJSqpEi7\nIaIWIov1bGw+YK3Yu0C8\r\n=Og1D\r\n-----END PGP MESSAGE-----\r\n"},"ParentID":"W2HUhfOT62HLdzaTBcFDysS-wNnNoYoKA74cuLCuxoGBCMrrUiIA7Mf2KRypP4QQV9mAqyP3FbBga4do6amPHQ==","Action":0}
I just noticed that there is a "ToList":[null] in the JSON request. Maybe this is what causes this crash?
Struct code:
-
MessageReq: https://github.com/emersion/neutron/blob/master/router/api/messages.go#L12 -
Message: https://github.com/emersion/neutron/blob/master/backend/messages.go#L4 -
Email: https://github.com/emersion/neutron/blob/master/backend/conversations.go#L21
I just noticed that there is a "ToList":[null] in the JSON request. Maybe this is what causes this crash?
Does remove "ToList":[null] fix the problem?
Yeah, that's what's causing the panic.
A null value in an array is not parsed as nil, a panic is triggered instead.