Uploaded image for project: 'Nuxeo Python Client'
  1. Nuxeo Python Client
  2. NXPY-170

Enforce NuxeoClient.server_info() robustness against invalid data

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.4.4
    • Fix Version/s: 3.0.0
    • Component/s: Core

      Description

      Error

      Here is the last traceback from a Nuxeo Drive hard crash:

      Traceback (most recent call last):
        File "nxdrive/__main__.py", line 119, in main
        File "nxdrive/commandline.py", line 539, in handle
        File "nxdrive/commandline.py", line 547, in get_manager
        File "nxdrive/manager.py", line 219, in __init__
        File "nxdrive/manager.py", line 448, in load
        File "nxdrive/engine/engine.py", line 172, in __init__
        File "nxdrive/engine/engine.py", line 977, in init_remote
        File "nxdrive/client/remote_client.py", line 135, in __init__
        File "site-packages/nuxeo/client.py", line 370, in server_version
        File "site-packages/nuxeo/client.py", line 360, in server_info
        File "site-packages/requests/models.py", line 898, in json
        File "json/__init__.py", line 348, in loads
        File "json/decoder.py", line 337, in decode
        File "json/decoder.py", line 355, in raw_decode
      json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
      

      Cf. https://github.com/nuxeo/nuxeo-python-client/blob/764c064/nuxeo/client.py#L359-L360.

      Analysis

      For whatever reason, the HTTP call to /json/cmis returned something else than JSON. And the condition was taken but the conversion using response.json() failed.

      Fix

      if isinstance(response, requests.Response):
          try:
              info = response.json()["default"]
          except ValueError:
              log.warning(...)
              info = None
      else:
          info = response
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mschoentgen Mickaël Schoentgen
                Reporter:
                mschoentgen Mickaël Schoentgen
                Participants:
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour
                  1h