Skip to content
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

Invalid type provided to filter causes 500 error instead of 400 #374

Closed
jonahsnider opened this issue Dec 28, 2019 · 0 comments · Fixed by #375
Closed

Invalid type provided to filter causes 500 error instead of 400 #374

jonahsnider opened this issue Dec 28, 2019 · 0 comments · Fixed by #375

Comments

@jonahsnider
Copy link

I mistyped a query for a getMany operation and the application had a 500 error. The 500 occurred because the database schema disallowed the malformed query to be run. In my case I was performing a filter for a boolean field, but in the query I provided I had added a ' to the end of my filter, so it became

-field||eq||false
+field||eq||false'

Rather than having the operation have a 400 due to a malformed query, the CRUD module tried to run it and was stopped by the database schema.
It gave the following stacktrace (note the ' after false):

QueryFailedError: invalid input syntax for type boolean: "false'"
    at new QueryFailedError (/usr/src/discoin/node_modules/typeorm/error/QueryFailedError.js:11:28)
    at Query.callback (/usr/src/discoin/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:176:38)
    at Query.handleError (/usr/src/discoin/node_modules/pg/lib/query.js:145:17)
    at Connection.connectedErrorMessageHandler (/usr/src/discoin/node_modules/pg/lib/client.js:214:17)
    at Connection.emit (events.js:210:5)
    at Socket.<anonymous> (/usr/src/discoin/node_modules/pg/lib/connection.js:128:12)
    at Socket.emit (events.js:210:5)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:290:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant