Uploaded image for project: 'openATTIC'
  1. openATTIC
  2. OP-1956

ValidationError exceptions are not processed correct by our custom error handler.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.18
    • Fix Version/s: 2.0.19
    • Component/s: Backend, Backend: API
    • Labels:
      None

      Description

      When a ValidationError exception is raised, e.g.

      if megs < 100:
          raise ValidationError({"megs": ["Volumes need to be at least 100MB in size."]})
      
      if self.type not in ("SATA", "SAS", "SSD"):
          raise ValidationError({"type": ["Type needs to be one of 'SATA', 'SAS', 'SSD'."]})
      

      the error message(s) of the erroneous field(s) are not processed correct by our custom error handler and Django in the later. This leads into an empty Response.content/Response.text variable or to be more precise, the error message is not forwarded to the API caller because it gets lost during the exception handling process.

      Note, if the ValidationError is raised with a single message string, e.g.

      if self.id is None:
          raise ValidationError('Creating OSDs is not supported.')
      

      then the final error message must be transformed into

      {"detail": "<THE_ORIGIN_ERROR_MESSAGE>"}
      

        Attachments

          Activity

            People

            Assignee:
            vtheile Theile, Volker
            Reporter:
            vtheile Theile, Volker
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: