Chemical-Curation / chemcurator_django

Backend services for chemical curation
https://api.chemreg.epa.gov
MIT License
1 stars 0 forks source link

Error on substance load #292

Open cmgrulke opened 3 years ago

cmgrulke commented 3 years ago

Describe the bug When I submit a substance to the API, I am receiving a internal service error an no substance is stored.

To Reproduce Steps to reproduce the behavior:

  1. Prepare Controlled Vocabularies for substanceType=single, qcLevel=dsstox-low, and source=public

  2. Submit the following body to */substances { "data": { "type": "substance", "attributes": { "casrn": "58139-47-2", "preferredName": "4-Bis(2-hydroxyethyl)amino-2-(2-thienyl)quinazoline" }, "relationships": { "qcLevel": { "data": { "type": "qcLevel", "id": "dsstox-low" } }, "source": { "data": { "type": "source", "id": "public" } }, "substanceType": { "data": { "type": "substanceType", "id": "single" } } }, "id": "DTXSID8020177" } }

  3. Receive error: ` <!doctype html>

    Server Error (500)

    Server Error (500)

    `

  4. Error from the log [04/Dec/2020 20:16:00] [ERROR] Internal Server Error: /substances Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute return self.cursor.execute(sql, params) psycopg2.errors.UndefinedFunction: operator does not exist: integer = character varying LINE 1: ...ity" ON ("substance_synonym"."synonym_quality_id" = "substan... ^ HINT: No operator matches the given name and argument types. You might need to add explicit type casts. The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "/usr/local/lib/python3.8/site-packages/rest_framework/viewsets.py", line 114, in view return self.dispatch(request, *args, **kwargs) File "/app/chemreg/jsonapi/views.py", line 15, in dispatch return super().dispatch(request, *args, **kwargs) File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 505, in dispatch response = self.handle_exception(exc) File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 465, in handle_exception self.raise_uncaught_exception(exc) File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 476, in raise_uncaught_exception raise exc File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 502, in dispatch response = handler(request, *args, **kwargs) File "/app/chemreg/jsonapi/views.py", line 31, in create return super().create(request, *args, **kwargs) File "/usr/local/lib/python3.8/site-packages/rest_framework/mixins.py", line 18, in create serializer.is_valid(raise_exception=True) File "/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py", line 234, in is_valid self._validated_data = self.run_validation(self.initial_data) File "/usr/local/lib/python3.8/site-packages/rest_framework/serializers.py", line 436, in run_validation value = self.validate(value) File "/app/chemreg/substance/serializers.py", line 210, in validate if set(chain(restricted_substance_fields, restricted_identifiers)): File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 276, in __iter__ self._fetch_all() File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 1261, in _fetch_all self._result_cache = list(self._iterable_class(self)) File "/usr/local/lib/python3.8/site-packages/django/db/models/query.py", line 57, in __iter__ results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size) File "/usr/local/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1144, in execute_sql cursor.execute(sql, params) File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 68, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers return executor(sql, params, many, context) File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute return self.cursor.execute(sql, params) File "/usr/local/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/usr/local/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute return self.cursor.execute(sql, params) django.db.utils.ProgrammingError: operator does not exist: integer = character varying LINE 1: ...ity" ON ("substance_synonym"."synonym_quality_id" = "substan... ^ HINT: No operator matches the given name and argument types. You might need to add explicit type casts.

Expected behavior I expect this substance to be stored (and it is not when subsequently listing the substances)

Desktop (please complete the following information):

Additional context This is observed on the stg deployment at https://ccte-api-chemreg-stg.epa.gov/substances

cmgrulke commented 3 years ago

But no bug in the new prod deployment.