OpenConceptLab / ocl_issues

Issues for all OCL repos. NOTE: Install ZenHub Browser Extension and request access to the OCL Roadmap board to view all issues and to contribute
4 stars 2 forks source link

oclapi2 creating undiscoverable concepts #417

Closed bmamlin closed 3 years ago

bmamlin commented 4 years ago

When testing out the OCL for OpenMRS client against API v2, I was able to create some concepts, but it appears they are not getting added to the collection as expected. I think I've tracked the problem down to this:

PUT https://api.qa2.openconceptlab.org/users/burke/collections/test/references/?cascade=sourcemappings
{
  "data": {
    "expressions": [
      "/users/burke/sources/test/concepts/3/"
    ]
  }
}

returning a 500 Internal Server Error

I've added two more concepts to my dictionary in the OCL client. I can see the concepts in the source, but the collection only shows the first concept with an invalid link (concepts 2 & 3 are missing from the collection).

Here's the trace from Django:

Request Method: PUT
Request URL: http://api.qa2.openconceptlab.org/users/burke/collections/test/references/?cascade=sourcemappings

Django Version: 3.0.9
Python Version: 3.8.3
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'rest_framework',
 'rest_framework.authtoken',
 'drf_yasg',
 'django_elasticsearch_dsl',
 'corsheaders',
 'core.common.apps.CommonConfig',
 'core.users',
 'core.orgs',
 'core.sources.apps.SourceConfig',
 'core.collections',
 'core.concepts',
 'core.mappings',
 'core.importers']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'core.middlewares.middlewares.FixMalformedLimitParamMiddleware',
 'core.middlewares.middlewares.RequestLogMiddleware']

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 145, 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 143, in _get_response
    response = response.render()
  File "/usr/local/lib/python3.8/site-packages/django/template/response.py", line 105, in render
    self.content = self.rendered_content
  File "/usr/local/lib/python3.8/site-packages/rest_framework/response.py", line 70, in rendered_content
    ret = renderer.render(self.data, accepted_media_type, context)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/renderers.py", line 100, in render
    ret = json.dumps(
  File "/usr/local/lib/python3.8/site-packages/rest_framework/utils/json.py", line 25, in dumps
    return json.dumps(*args, **kwargs)
  File "/usr/local/lib/python3.8/json/__init__.py", line 234, in dumps
    return cls(
  File "/usr/local/lib/python3.8/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python3.8/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python3.8/site-packages/rest_framework/utils/encoders.py", line 67, in default
    return super().default(obj)
  File "/usr/local/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '

Exception Type: TypeError at /users/burke/collections/test/references/
Exception Value: Object of type FieldError is not JSON serializable
snyaggarwal commented 4 years ago

This was a strict code bug, bad queryset filtering for OpenMRS schema validation. This is fixed and deployed to QA.

aprilcurrier commented 4 years ago

@snyaggarwal @bmamlin can this be closed or does it require additional review?

snyaggarwal commented 4 years ago

This can be closed

aprilcurrier commented 4 years ago

@snyaggarwal to confirm with Burke this has been tested in order to close

aprilcurrier commented 3 years ago

Burke Mentioned on a call this is working