New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.5
7.4.0
OSX
Steps to reproduce your error
./node_modules/.bin/actionhero generate
Run a
curl
request: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.
The text was updated successfully, but these errors were encountered: