Parsing form values doesn't seem to be working correctly in the request handlers #11

Closed
waynegerard opened this Issue Mar 31, 2016 · 6 comments

Comments

Projects
None yet
4 participants
Contributor

waynegerard commented Mar 31, 2016

I've been playing around with this but haven't quite gotten a patch together yet.

It seems like there's an issue with decoding the form values from a JSON post request - namely, it doesn't see the payload as form values and so values (e.g. name, email, fid) are all blank when going to read them.

Entirely possible this is an OS issue: I haven't tried on any other OS (running OS X 10.11.3).

I suspect it might be more robust to treat the payload as JSON and use a JSON decoder instead, but I'm mostly curious if other people are having the same issue.

Contributor

waynegerard commented Mar 31, 2016

As an aside, because it's moot if this gets patched to decode JSON instead: I think r.FormValue() will also read from query params, which is probably not ideal. Should probably be r.PostFormValue() instead.

Having the same issue and came here for a look - I think you're right. r.ParseForm can't parse JSON.

I think I'm having a similar issue. If you log in with invalid credentials, you get redirected /profile with blank details even though its failed. Chrome outputs:

Object {Msg: "Invalid username/password combination"}
main.js:2112 GET http://localhost:4200/api/user/profile.json 500 (Internal Server Error)
main.js:2782 Object {Msg: "strconv.ParseInt: parsing 'undefined': invalid syntax"}
main.js:2112 PUT http://localhost:4200/api/user/profile.json 500 (Internal Server Error)
main.js:2793 hit

I will test it with JSON decode instead when I get a chance and see if that sticks

Log output:

failed strconv.ParseInt: parsing "undefined": invalid syntax
Contributor

egtann commented Mar 31, 2016

Thanks guys. We should definitely be using json.Decode here. Diving in now.

Contributor

egtann commented Mar 31, 2016

This should be fixed by the new pull request #14. If you still get errors, please create a new issue, and we'll debug them there.

Best,

Evan

egtann closed this Mar 31, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment