goodman
goodman copied to clipboard
Error when API sets a cookie
Whenever my API responds with a header Set-Cookie
, I get the error info: Hook handler stderr: panic: RPC client threw error gob: type not registered for interface: []interface {}
I have narrowed this down to the Set-Cookie
header. If I name the header anything else, it doesn't give me that error, but when I name it Set-Cookie
I always get that error.
Thank you for the error report, can you please post your hookfiles and I should have some time to dig into this tonight.
Here is the more complete detailed error it gives:
info: Hook handler stderr: panic(0x354580, 0xc82021a6e0)
/usr/local/Cellar/go/1.6.2/libexec/src/runtime/panic.go:481 +0x3e6
github.com/snikch/goodman.(*Run).RunBeforeEachValidation(0xc82015c3a0, 0xc820220000)
/Users/jcarl/gocode/src/github.com/snikch/goodman/runner.go:62 +0x1fd
github.com/snikch/goodman.(*Server).RunBeforeEachValidation(0xc82011dee8, 0xc820220000)
/Users/jcarl/gocode/src/github.com/snikch/goodman/server.go:153 +0x93
github.com/snikch/goodman.(*Server).ProcessMessage(0xc82011dee8, 0xc820208600, 0x0, 0x0)
/Users/jcarl/gocode/src/github.com/snikch/goodman/server.go:108 +0x761
github.com/snikch/goodman.(*Server).Run(0xc82011dee8, 0x0, 0x0)
/Users/jcarl/gocode/src/github.com/snikch/goodman/server.go:70 +0x6ae
main.main()
/Users/jcarl/gocode/src/github.com/snikch/goodman/cmd/goodman/main.go:60 +0x3fe
error: Hook handler '/Users/jcarl/gocode/bin/goodman' exited with status: 2
warn: Hook handling timed out.
error: Hook handler '/Users/jcarl/gocode/bin/goodman' exited with status: 2
Will post hookfiles in a sec.
I was able to replicate the issue with an example setup. Here is the example: https://github.com/grounded042/goodman-set-cookie. I did not add any hooks to show that it happens without writing any hooks but just by compiling the hooks and running dredd
.
@grounded042 so I am able to reproduce the issue and also am pretty confident I know why it is occurring. This line here will create a header like so
Headers:
set-cookie: ["Test=Yo"]
Since goodman uses RPC to execute the hooks, the transactions are encoded / decoded via the gob package. It seems to be that when the above header structure is mixed with key value pairs like Content-Type: 123
it has problems.
I think the solution is to treat header values always like map[string][]string
so I need to change how the json data sent from Dredd is unmarshaled so that the data type of the Headers is always the same type.
I am gonna be away this weekend but I will try to resolve this issue as soon as I can.
Sweet! Thanks for taking a look.
@grounded042 a little update, I am struggling to reproduce this in a testing environment because I am trying to add a new cucumber / aruba test and since I am not a ruby guy I am having problems writing the test. Hoping to have something updated this week however.