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 empty update $set/$unset #1727

Open toptobes opened 1 week ago

toptobes commented 1 week ago

not much else to say here

CommandFailedEvent {
  command: {
    updateOne: {
      filter: { text: '3c240574-1613-4f65-a2fe-732d8e52a46e', int: 0 },
      update: { '$set': {} },
      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: 3070.757375000001,
  error: DataAPIHttpError: HTTP error (500): {"errors":[{"message":"Server failed: root cause: (java.lang.IllegalArgumentException) assignments must not be empty","errorCode":"SERVER_UNHANDLED_ERROR","id":"6e3cd17a-fc0d-4f07-bb9c-a6b316262033","title":"Server failed","family":"SERVER","scope":"DATABASE"}]}
     ... {
    status: 500,
    body: '{"errors":[{"message":"Server failed: root cause: (java.lang.IllegalArgumentException) assignments must not be empty","errorCode":"SERVER_UNHANDLED_ERROR","id":"6e3cd17a-fc0d-4f07-bb9c-a6b316262033","title":"Server failed","family":"SERVER","scope":"DATABASE"}]}',
    raw: {
      headers: {
        server: 'openresty/1.25.3.1',
        date: 'Fri, 15 Nov 2024 05:57:50 GMT',
        'content-type': 'application/json;charset=UTF-8',
        'content-length': '262'
      },
      body: '{"errors":[{"message":"Server failed: root cause: (java.lang.IllegalArgumentException) assignments must not be empty","errorCode":"SERVER_UNHANDLED_ERROR","id":"6e3cd17a-fc0d-4f07-bb9c-a6b316262033","title":"Server failed","family":"SERVER","scope":"DATABASE"}]}',
      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: ignore any update operations with null or empty object. We should also check if this is happening for collections.