Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
GET request of schema inputs causes error #1042
Comments
|
@chimmelb your middleware seems like a good option for a fix, especially because it only messes with schema-type actions. |
|
Thanks for issue. |
|
I'm using that middleware I posted so this isn't a showstopper, but thought I'd report it. If the schema input wasn't an object, I could see rejecting the entire action (and I'd still need my |
|
BTW, I think the source of the difference in behavior between GET and everything else is here https://github.com/actionhero/actionhero/blob/master/servers/web.js#L481-L489 We try to parse uploaded params as a form, which de-URL encodes them, and sorts them out... only when it is not a GET or HEAD. Perhaps we need to also try to parse URL params in a similar way. The more I think about this, the more this might be a server issue and not an action issue. |
|
I did notice that inside middleware the schema input was a JSON string, not an URL encoded string. It is getting decoded, just not |
Name of Issue
GET request of schema inputs throw error.
Workaround is to use POST or write middleware (example below)
16.0.57.4.0OSXSteps to reproduce your error
./node_modules/.bin/actionhero generateRun a
curlrequest:This is a URL encoded JSON object
{"in1":1,"in2":"in2"}and I receive this error:POSTing a request works fine:
I thought to create a middleware to error
405 Method Not Allowed, but this occurs in the input processing of an action after preProcessor middleware. https://github.com/actionhero/actionhero/blob/v16.0.5/initializers/actionProcessor.js#L289-L291, so the validation is run on error anyway.A workaround is to add some parsing middleware like this:
Of course, invalid JSON will throw and like any middleware that validation will still be run and hit the bug.
Copying @witem for ideas.