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 500 on fields overlapping in $set & $unset #1728

Open toptobes opened 1 week ago

toptobes commented 1 week ago
CommandFailedEvent {
  command: {
    updateOne: {
      filter: { text: '92b038cd-e70e-4e47-88da-6dbc749c6a77', int: 0 },
      update: { '$set': { tinyint: 4 }, '$unset': { tinyint: '' } },
      options: { upsert: undefined }
    }
  },
  keyspace: 'default_keyspace',
  source: 'test_table',
  commandName: 'updateOne',
  url: 'https://c60822b2-b054-4874-978e-5c1c06ce8d54-us-west-2.apps.astra-dev.datastax.com/api/json/v1/default_keyspace/test_table',
  duration: 3071.164334,
  error: DataAPIHttpError: HTTP error (500): {"errors":[{"message":"An unexpected server error occurred while processing the request. \n\nError Class: SyntaxError\nError Message: Multiple incompatible setting of column tinyint","scope":"","errorCode":"UNEXPECTED_SERVER_ERROR","id":"9b6b8207-8bd5-40a7-b71a-9b53f3efc4c9","family":"SERVER","title":"Unexpected server error"}]}
      ... {
    status: 500,
    body: '{"errors":[{"message":"An unexpected server error occurred while processing the request. \\n\\nError Class: SyntaxError\\nError Message: Multiple incompatible setting of column tinyint","scope":"","errorCode":"UNEXPECTED_SERVER_ERROR","id":"9b6b8207-8bd5-40a7-b71a-9b53f3efc4c9","family":"SERVER","title":"Unexpected server error"}]}',
    raw: {
      headers: {
        server: 'openresty/1.25.3.1',
        date: 'Fri, 15 Nov 2024 06:20:10 GMT',
        'content-type': 'application/json;charset=UTF-8',
        'content-length': '330'
      },
      body: '{"errors":[{"message":"An unexpected server error occurred while processing the request. \\n\\nError Class: SyntaxError\\nError Message: Multiple incompatible setting of column tinyint","scope":"","errorCode":"UNEXPECTED_SERVER_ERROR","id":"9b6b8207-8bd5-40a7-b71a-9b53f3efc4c9","family":"SERVER","title":"Unexpected server error"}]}',
      status: 500,
      url: 'https://c60822b2-b054-4874-978e-5c1c06ce8d54-us-west-2.apps.astra-dev.datastax.com/api/json/v1/default_keyspace/test_table',
      httpVersion: 2,
      statusText: ''
    }
  }
}
amorton commented 2 days ago

fix probably: we are not validating rules for what update operations tables can do, collections are checking this and the command would get an APi error. So we need to make the tables code generate a nice error.

Also, the bad error from the driver is the problem with not all drive errors being translated which will be fixed.