mikeflynn / go-alexa

A collection of Amazon Echo / Alexa tools for Go development.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jeopardy Example is not bumped to newest context import

kumarde opened this issue · comments

Hi,

This is a great library! I'm trying to get the Jeopardy example up and running.

What I've done

  1. Set up an alexa skills w/ intents + utterances
  2. Run the skillserver example by running go build inside of the jeopardy directory
  3. Attempt to send a test to my endpoint, with the phrase "start a game"

I get the following stacktrace from the ./jeopardy program:

[negroni] PANIC: interface conversion: interface {} is nil, not *skillserver.EchoRequest
goroutine 6 [running]:
github.com/urfave/negroni.(*Recovery).ServeHTTP.func1(0x7ffba4187058, 0xc42000e0e8, 0xc420015ad0)
	/home/kumarde/go/src/github.com/urfave/negroni/recovery.go:41 +0x13a
panic(0x7ea220, 0xc4203e0e80)
	/usr/local/go/src/runtime/panic.go:489 +0x2cf
main.EchoJeopardy(0x7ffba4187058, 0xc42000e0f8, 0xc42000b100)
	/home/kumarde/go/src/github.com/mikeflynn/go-alexa/skillserver/examples/jeopardy/jeopardy.go:104 +0x1543
net/http.HandlerFunc.ServeHTTP(0x870df8, 0x7ffba4187058, 0xc42000e0f8, 0xc42000b100)
	/usr/local/go/src/net/http/server.go:1942 +0x44
github.com/gorilla/mux.(*Router).ServeHTTP(0xc4200165f0, 0x7ffba4187058, 0xc42000e0f8, 0xc42000b100)
	/home/kumarde/go/src/github.com/gorilla/mux/mux.go:114 +0x10c
github.com/urfave/negroni.Wrap.func1(0x7ffba4187058, 0xc42000e0f8, 0xc42000a900, 0xc4200aa980)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:46 +0x4d
github.com/urfave/negroni.HandlerFunc.ServeHTTP(0xc4200aaba0, 0x7ffba4187058, 0xc42000e0f8, 0xc42000a900, 0xc4200aa980)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:29 +0x4e
github.com/urfave/negroni.middleware.ServeHTTP(0xa24b80, 0xc4200aaba0, 0xc4200aac00, 0x7ffba4187058, 0xc42000e0f8, 0xc42000a900)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:38 +0xb4
github.com/urfave/negroni.(middleware).ServeHTTP-fm(0x7ffba4187058, 0xc42000e0f8, 0xc42000a900)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:38 +0x60
github.com/mikeflynn/go-alexa/skillserver.verifyJSON(0x7ffba4187058, 0xc42000e0f8, 0xc42000ae00, 0xc42000c360)
	/home/kumarde/go/src/github.com/mikeflynn/go-alexa/skillserver/skillserver.go:152 +0x37d
github.com/urfave/negroni.HandlerFunc.ServeHTTP(0x870a48, 0x7ffba4187058, 0xc42000e0f8, 0xc42000ae00, 0xc42000c360)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:29 +0x4e
github.com/urfave/negroni.middleware.ServeHTTP(0xa24b80, 0x870a48, 0xc4200aabe0, 0x7ffba4187058, 0xc42000e0f8, 0xc42000ae00)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:38 +0xb4
github.com/urfave/negroni.(middleware).ServeHTTP-fm(0x7ffba4187058, 0xc42000e0f8, 0xc42000ae00)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:38 +0x60
github.com/mikeflynn/go-alexa/skillserver.validateRequest(0x7ffba4187058, 0xc42000e0f8, 0xc42000ae00, 0xc4200ab0a0)
	/home/kumarde/go/src/github.com/mikeflynn/go-alexa/skillserver/skillserver.go:169 +0xe0
github.com/urfave/negroni.HandlerFunc.ServeHTTP(0x870a40, 0x7ffba4187058, 0xc42000e0f8, 0xc42000ae00, 0xc4200ab0a0)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:29 +0x4e
github.com/urfave/negroni.middleware.ServeHTTP(0xa24b80, 0x870a40, 0xc4200aabc0, 0x7ffba4187058, 0xc42000e0f8, 0xc42000ae00)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:38 +0xb4
github.com/urfave/negroni.(*Negroni).ServeHTTP(0xc4200158f0, 0x7ffba4187058, 0xc42000e0e8, 0xc42000ae00)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:86 +0x10d
github.com/gorilla/mux.(*Router).ServeHTTP(0xc4200165a0, 0x7ffba4187058, 0xc42000e0e8, 0xc42000ae00)
	/home/kumarde/go/src/github.com/gorilla/mux/mux.go:114 +0x10c
github.com/urfave/negroni.Wrap.func1(0x7ffba4187058, 0xc42000e0e8, 0xc42000ac00, 0xc4200ab060)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:46 +0x4d
github.com/urfave/negroni.HandlerFunc.ServeHTTP(0xc4200aade0, 0x7ffba4187058, 0xc42000e0e8, 0xc42000ac00, 0xc4200ab060)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:29 +0x4e
github.com/urfave/negroni.middleware.ServeHTTP(0xa24b80, 0xc4200aade0, 0xc4200aae60, 0x7ffba4187058, 0xc42000e0e8, 0xc42000ac00)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:38 +0xb4
github.com/urfave/negroni.(middleware).ServeHTTP-fm(0x7ffba4187058, 0xc42000e0e8, 0xc42000ac00)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:38 +0x60
github.com/urfave/negroni.(*Static).ServeHTTP(0xc4201100c0, 0x7ffba4187058, 0xc42000e0e8, 0xc42000ac00, 0xc4200ab040)
	/home/kumarde/go/src/github.com/urfave/negroni/static.go:34 +0x8c
github.com/urfave/negroni.middleware.ServeHTTP(0xa232c0, 0xc4201100c0, 0xc4200aae40, 0x7ffba4187058, 0xc42000e0e8, 0xc42000ac00)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:38 +0xb4
github.com/urfave/negroni.(middleware).ServeHTTP-fm(0x7ffba4187058, 0xc42000e0e8, 0xc42000ac00)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:38 +0x60
github.com/urfave/negroni.(*Logger).ServeHTTP(0xc420015b00, 0x7ffba4187058, 0xc42000e0e8, 0xc42000ac00, 0xc4200ab020)
	/home/kumarde/go/src/github.com/urfave/negroni/logger.go:65 +0x89
github.com/urfave/negroni.middleware.ServeHTTP(0xa23200, 0xc420015b00, 0xc4200aae20, 0x7ffba4187058, 0xc42000e0e8, 0xc42000ac00)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:38 +0xb4
github.com/urfave/negroni.(middleware).ServeHTTP-fm(0x7ffba4187058, 0xc42000e0e8, 0xc42000ac00)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:38 +0x60
github.com/urfave/negroni.(*Recovery).ServeHTTP(0xc420015ad0, 0x7ffba4187058, 0xc42000e0e8, 0xc42000ac00, 0xc4200ab000)
	/home/kumarde/go/src/github.com/urfave/negroni/recovery.go:64 +0x82
github.com/urfave/negroni.middleware.ServeHTTP(0xa23280, 0xc420015ad0, 0xc4200aae00, 0x7ffba4187058, 0xc42000e0e8, 0xc42000ac00)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:38 +0xb4
github.com/urfave/negroni.(*Negroni).ServeHTTP(0xc420110120, 0xa28180, 0xc42010e0e0, 0xc42000ac00)
	/home/kumarde/go/src/github.com/urfave/negroni/negroni.go:86 +0x10d
net/http.serverHandler.ServeHTTP(0xc42001b760, 0xa28180, 0xc42010e0e0, 0xc42000ac00)
	/usr/local/go/src/net/http/server.go:2568 +0x92
net/http.(*conn).serve(0xc4200bb900, 0xa289c0, 0xc42001e7c0)
	/usr/local/go/src/net/http/server.go:1825 +0x612
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2668 +0x2ce

Has anyone seen this before?

commented

How are you sending the request to your endpoint? Is it through the Alexa request simulator? If it isn’t properly formatted it may not be able to decide it into an EchoRequest if is is missing fields.

I'm sending the request to my endpoint via the Alexa request simulator. it looks like this:

{
  "session": {
    "sessionId": "SessionId.81394ce6-6fce-451e-a6b9-eefbb5c23c0c",
    "application": {
      "applicationId": "amzn1.ask.skill.810a5007-254d-489f-b2e3-f6c35d215bef"
    },
    "attributes": {},
    "user": {
      "userId": "amzn1.ask.account.AGTN5PAYVQYAYSK6AJQEU34WMCBGKK4NP25U3A6YJ6FRFPVMMZTLDYKNYKFOZG26V4RMXSJKO5BDHY4IHZ2KEN2D7DFDVCMCY73IHWR7WC34KHEVREN4WWEZZZLVL7TE6JOQOXYYEKXQWFDP5LBJWUYSISHTYJB7EWGTGEJCAB6D64D3EDHTQIX4IHUBW6HJSCPH6NTF7GQMKZA"
    },
    "new": true
  },
  "request": {
    "type": "IntentRequest",
    "requestId": "EdwRequestId.f5e570a3-c374-4d7c-b61b-f7758d772094",
    "locale": "en-US",
    "timestamp": "2017-07-18T15:02:28Z",
    "intent": {
      "name": "StartJeopardy",
      "slots": {}
    }
  },
  "version": "1.0"
}

Closing this issue - the problem was the the jeopardy.go examples still relied on github.com/gorilla/context rather than the native GoLang context. Cheers!

commented

Is that a change that should be merged in so others don't run into this issue? Glad you got it figured out.

Happy to.

Thank you and good catch! Merged in your Pull Request.