Uploaded image for project: 'Webservices REST Module'
  1. Webservices REST Module
  2. RESTWS-899

Validation errors unusable for troubleshooting

    XMLWordPrintable

Details

    • Enhancement
    • Status: Closed
    • Should
    • Resolution: Fixed
    • None
    • 2.37.0
    • None
    • Medium

    Description

      I’m using reference app 12.2, posting new encounters for the first time. The REST validation errors need to communicate the detail of each error; currently it just swallows it and does not allow the integration developer to debug the situation.

      Example 1: POST encounter

      Whenever there is a validation error, OpenMRS just returns a very cryptic message like:

      Request processing failed; nested exception is org.openmrs.module.webservices.rest.web.response.ConversionException: observations on class org.openmrs.Encounter}}
      

      or the same ConversionException with: 

      encounterDatetime on class org.openmrs.Encounter
      

      So, after trial and error on the 2nd one, it seems OpenMRS doesn’t like microseconds in the date format. The REST validation errors need to communicate the detail of each error.

      Example 2: POST programenrollment:

      If I post an invalid ISO date-time for `dateEnrolled` by replacing the 'T' with a space (e.g. "2022-09-05 10:00:02+02:00" instead of "of "2022-09-05T10:00:02+02:00", I get a semi-useful error:
       

      Request processing failed; nested exception is org.openmrs.module.webservices.rest.web.response.ConversionException: dateEnrolled on class org.openmrs.PatientProgram
      

      but if I leave out the timezone offset, e.g. make `dateEnrolled` = "2022-09-05T10:00:02", I get the very unhelpful: 

      No serializer found for class org.springframework.validation.DefaultMessageCodesResolver and no properties discovered to create BeanSerializer (to avoid exception, disable   SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain:
              org.openmrs.module.webservices.validation.ValidationException["errors"]->org.springframework.validation.BindException["bindingResult"]->org.springframework.validation.BeanPropertyBindingResult["messageCodesResolver"])
      

      which looks like an exception inside the exception handling!

      And the log entry for this is similarly useless:

      WARN - ExceptionHandlerExceptionResolver.doResolveHandlerMethodException(414) |2022-09-05T09:51:11,632| Failure in @ExceptionHandler org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController#validationExceptionHandler(ValidationException, HttpServletRequest, HttpServletResponse)
      org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class org.openmrs.module.webservices.rest.SimpleObject
      

      Most exceptions on incorrect input data are of the latter type, i.e. the `BindException`, with "No converter found for... SimpleObject".

       

       

      Gliffy Diagrams

        Attachments

          Activity

            People

              dkayiwa Daniel Kayiwa
              cornelmasson Cornel Masson
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: