Molecular-Biophysics-Database / mbdb-app

The complete application
MIT License
0 stars 0 forks source link

deposition form - Server error when trying to save #96

Closed edager closed 7 months ago

edager commented 11 months ago

While trying to save after entering solvent details, I got this error message (09:00 23/11-2023)

500 error

Trying again at 09:04 it appeared to have saved…

edager commented 11 months ago

This is likely related to a previously observed error that occurs for incompletely filled objects. The cause appears to be that partially filling certain elements results in the frontend returns an array instead of an object which gives rise to a json schema validation error (example error):

"PUT /api/mbdb-mst/7tsz3-ss856/draft HTTP/1.1" 500 -
.
.
.
jsonschema.exceptions.ValidationError: [{'inchikey': 'something long ', 'molecular_weight': {'unit': 'kDa', 'value': 7.0}, 'name': 'long name', 'type': 'Chemical'}] is not of type 'object'
MadCatX commented 11 months ago

Getting a 500 here is odd. If the frontend deposited invalid data, the backend should catch it report it back with a 400 (?) error code. Solvent is supposed to be a list of Entity items so having an array here seems correct.

edager commented 7 months ago

A working minimal example to provoke this error is to post the following:

{
  "metadata": {
    "general_parameters": {
      "depositors": {
        "principal_contact": {
          "family_name": "d",
          "given_name": "e"
        }
      },
      "entities_of_interest": [
        {
          "type": "Polymer",
          "name": "l"
        }
      ]
    }
  }
}

Note that the following (also incomplete) example that gives the intended behaviour is:

{
  "metadata": {
    "general_parameters": {
      "depositors": {
        "principal_contact": {
          "family_name": "d",
          "given_name": "e"
        }
      }
    }
  }
}
edager commented 7 months ago

This was fixed the affected dependency, see https://github.com/oarepo/oarepo-runtime/pull/172