Uploaded image for project: 'Nuxeo Drive '
  1. Nuxeo Drive
  2. NXDRIVE-2517

[Direct Edit] Fix Qt slot signature preventing to edit custom xpath

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 4.5.1
    • Fix Version/s: 5.0.0
    • Component/s: Direct Edit
    • Release Notes Summary:
      Fixed a capability to edit custom xpath
    • Release Notes Description:
      Hide

      A regression introduced in 4.5.1 where it was no more possible to use the Direct Edit feature on a custom xpath has been fixed.

      Show
      A regression introduced in 4.5.1 where it was no more possible to use the Direct Edit feature on a custom xpath has been fixed.
    • Sprint:
      nxDrive 11.2.13
    • Story Points:
      1

      Description

      Problem

      The consequent improvement done in 4.5.1 with NXDRIVE-1768 introduced a bug in few Qt slots arguments.

      Analysis

      Drive is using a Qt signal to launch Direct Edit on a given document.

      The function recieving the signal has that signature:

      @pyqtSlot(str, str, str, str)
      def edit(self, server_url: str, doc_id: str, /, *, user: str = None, download_url: str = None) -> None:
          # ...
      

      In recent Python versions (3.8+), / means that all arguments on its left are "positional-only", e.g: one must call the function like edit(arg1, arg2, ...) and edit(server_url=arg1, doc_id=arg2, ...) is forbidden.
      * means that all arguments at is right are "keyword-only", e.g.: one must pass a key=value pair for those arguments such as user="alice" and download_url="...".

      Combined, that means we forced the function to be called like:

      edit("https://...", "123-456-789-0", user="alice", download_url="nxfile/...")
      

      But the Qt signal does not understand that new notation: it recieved 4 arguments and does not care if one is "position-only" or "keyword-only".
      Results: user and download_url were always set to None.

      That's the root cause of the problem.

      Then, Drive was seeing an empty download_url and so it was using the default blob location, which is file:content (download_url is used to guess an eventual custom xpath).
      But that xpath was not found as blobs are effectively stored elsewhere.

      Verification

      That command mimics a click on the Direct Edit button in from Web-UI:

      $ python -m nxdrive "nxdrive://edit/http/192.168.2.39:8080/nuxeo/user/ndt-robert-67422/repo/default/nxdocid/152fc209-f946-4d3b-b128-485d21172be0/filename/attachment.txt/downloadUrl/nxfile/default/152fc209-f946-4d3b-b128-485d21172be0/files:files/0/file/attachment.txt"
      

      In 4.5.1, Drive will recieve those arguments:

      Direct Editing doc_id='152fc209-f946-4d3b-b128-485d21172be0' on server_url='http://192.168.2.39:8080/nuxeo' for user=None with download_url=None
      

      In 4.5.0 and upcoming 5.0.0:

      Direct Editing doc_id='152fc209-f946-4d3b-b128-485d21172be0' on server_url='http://192.168.2.39:8080/nuxeo' for user='ndt-robert-67422' with download_url='nxfile/default/152fc209-f946-4d3b-b128-485d21172be0/files:files/0/file/attachment.txt'
      

      Edit: a similar issue was present in EngineModel.get().

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 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 - 2 hours
                  2h