stargate / data-api

JSON document API for Apache Cassandra (formerly known as JSON API)
https://stargate.io
Apache License 2.0
14 stars 16 forks source link

HTTP 500s on `InvalidQueryException`s #1719

Open toptobes opened 1 week ago

toptobes commented 1 week ago

InvalidQueryException sometimes (but not always, I believe?) throws HTTP 500s (not sure under which conditions it throws a 500 instead of returning an errored 200)

e.g. w/ { insertOne: { document: { text: '', int: 0 } } }, I got:

DataAPIHttpError: HTTP error (500): {"errors":[{"message":"An unexpected server error occurred while processing the request. \n\nError Class: InvalidQueryException\nError Message: Key may not be empty","scope":"","errorCode":"UNEXPECTED_SERVER_ERROR","id":"2012bdd7-f01b-4d4c-9422-3d5cee88ce1f","family":"SERVER","title":"Unexpected server error"}]}

or with { insertOne: { document: { text: 'a'.repeat(65535), int: 0 } } }, I got:

DataAPIHttpError: HTTP error (500): {"errors":[{"message":"An unexpected server error occurred while processing the request. \n\nError Class: InvalidQueryException\nError Message: Key length of 65536 is longer than maximum of 65535","scope":"","errorCode":"UNEXPECTED_SERVER_ERROR","id":"3db1e627-97e0-4fc8-a073-c5722a258be7","family":"SERVER","title":"Unexpected server error"}]}

however, I'm pretty sure I've gotten 200s with these in the past (tested on both local & dev)

amorton commented 5 days ago

fix: we did not get to translate all of the driver errors, this should be fixed in that. Leaving open for testing.

Also fix: need more validation on the rules for values in CQL when they are part of the primary key , check the C* code base for other rules.