Skip to content

Bug: Folder names with trailing spaces cause migration failure (Google Drive / Photos) #208

@AhsanIsEpic

Description

@AhsanIsEpic

Which version of integration_google are you using?

3.2.0

Which version of Nextcloud are you using?

31.0.2.1

Which browser are you using? In case you are using the phone App, specify the Android or iOS version and device please.

Microsoft Edge Version 135.0.3179.73 (Official build) (64-bit)

Describe the Bug

When importing folders from Google Drive or Google Photos with a space at the end of the folder name, the data migration process fails completely. In contrast, files with trailing spaces have the space replaced by a "-" and proceed without error.

Error behaviour
On the first migration attempt, the following issues appear in order:

1. Failure to create folder (NonExistingFolder)
{
  "reqId": "[REDACTED]",
  "level": 3,
  "time": "[REDACTED]",
  "remoteAddr": "",
  "user": "[REDACTED]",
  "app": "admin_audit",
  "method": "",
  "url": "--",
  "message": "Exception thrown in file create: ",
  "userAgent": "--",
  "version": "31.0.2.1",
  "exception": {
    "Exception": "OCP\\Files\\NotFoundException",
    "Message": "",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/html/apps/admin_audit/lib/Actions/Files.php",
        "line": 103,
        "function": "getId",
        "class": "OC\\Files\\Node\\NonExistingFolder",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/apps/admin_audit/lib/AppInfo/Application.php",
        "line": 188,
        "function": "create",
        "class": "OCA\\AdminAudit\\Actions\\Files",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
        "line": 220,
        "function": "OCA\\AdminAudit\\AppInfo\\{closure}",
        "class": "OCA\\AdminAudit\\AppInfo\\Application",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/3rdparty/symfony/event-dispatcher/EventDispatcher.php",
        "line": 56,
        "function": "callListeners",
        "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          [
            {
              "__class__": "Closure"
            },
            {
              "__class__": "Closure"
            },
            {
              "__class__": "Closure"
            }
          ],
          "*** sensitive parameters replaced ***",
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
        "line": 67,
        "function": "dispatch",
        "class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***",
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/lib/private/EventDispatcher/EventDispatcher.php",
        "line": 79,
        "function": "dispatch",
        "class": "OC\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***",
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/Node/HookConnector.php",
        "line": 101,
        "function": "dispatchTyped",
        "class": "OC\\EventDispatcher\\EventDispatcher",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/lib/private/legacy/OC_Hook.php",
        "line": 85,
        "function": "postCreate",
        "class": "OC\\Files\\Node\\HookConnector",
        "type": "->",
        "args": [
          {
            "run": true,
            "path": "/Google Drive/I got a space at the end "
          }
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/View.php",
        "line": 1321,
        "function": "emit",
        "class": "OC_Hook",
        "type": "::",
        "args": [
          "OC_Filesystem",
          "post_create",
          {
            "run": true,
            "path": "/Google Drive/I got a space at the end "
          }
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/View.php",
        "line": 1253,
        "function": "runHooks",
        "class": "OC\\Files\\View",
        "type": "->",
        "args": [
          [
            "create",
            "write"
          ],
          "/Google Drive/I got a space at the end ",
          true
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/View.php",
        "line": 211,
        "function": "basicOperation",
        "class": "OC\\Files\\View",
        "type": "->",
        "args": [
          "mkdir",
          "/[REDACTED]/files/Google Drive/I got a space at the end ",
          [
            "create",
            "write"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/Node/Folder.php",
        "line": 129,
        "function": "mkdir",
        "class": "OC\\Files\\View",
        "type": "->",
        "args": [
          "/[REDACTED]/files/Google Drive/I got a space at the end "
        ]
      },
      {
        "file": "/var/www/html/custom_apps/integration_google/lib/Service/GoogleDriveAPIService.php",
        "line": 544,
        "function": "newFolder",
        "class": "OC\\Files\\Node\\Folder",
        "type": "->",
        "args": [
          "I got a space at the end "
        ]
      },
      {
        "file": "/var/www/html/custom_apps/integration_google/lib/Service/GoogleDriveAPIService.php",
        "line": 290,
        "function": "createDirsUnder",
        "class": "OCA\\Google\\Service\\GoogleDriveAPIService",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/custom_apps/integration_google/lib/Service/GoogleDriveAPIService.php",
        "line": 188,
        "function": "importFiles",
        "class": "OCA\\Google\\Service\\GoogleDriveAPIService",
        "type": "->",
        "args": [
          "[REDACTED]",
          "/Google Drive",
          500000000,
          0,
          0,
          []
        ]
      },
      {
        "file": "/var/www/html/custom_apps/integration_google/lib/BackgroundJob/ImportDriveJob.php",
        "line": 36,
        "function": "importDriveJob",
        "class": "OCA\\Google\\Service\\GoogleDriveAPIService",
        "type": "->",
        "args": [
          "[REDACTED]"
        ]
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/Job.php",
        "line": 61,
        "function": "run",
        "class": "OCA\\Google\\BackgroundJob\\ImportDriveJob",
        "type": "->",
        "args": [
          {
            "user_id": "[REDACTED]"
          }
        ]
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/QueuedJob.php",
        "line": 43,
        "function": "start",
        "class": "OCP\\BackgroundJob\\Job",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\BackgroundJob\\JobList"
          }
        ]
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/QueuedJob.php",
        "line": 29,
        "function": "start",
        "class": "OCP\\BackgroundJob\\QueuedJob",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\BackgroundJob\\JobList"
          }
        ]
      },
      {
        "file": "/var/www/html/cron.php",
        "line": 170,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\QueuedJob",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\BackgroundJob\\JobList"
          }
        ]
      }
    ],
    "File": "/var/www/html/lib/private/Files/Node/NonExistingFolder.php",
    "Line": 37,
    "message": "Exception thrown in file create: ",
    "exception": [],
    "CustomMessage": "Exception thrown in file create: "
  },
  "id": "[REDACTED]"
}
2. File system not found (OCP\Files\NotFoundException)
{
  "reqId": "[REDACTED]",
  "level": 3,
  "time": "[REDACTED]",
  "remoteAddr": "",
  "user": "[REDACTED]",
  "app": "no app in context",
  "method": "",
  "url": "--",
  "message": "Exception thrown: OCP\\Files\\NotFoundException",
  "userAgent": "--",
  "version": "31.0.2.1",
  "exception": {
    "Exception": "OCP\\Files\\NotFoundException",
    "Message": "",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/html/lib/private/Files/Node/Node.php",
        "line": 359,
        "function": "getFileInfo",
        "class": "OC\\Files\\Node\\Node",
        "type": "->",
        "args": [
          false
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/Node/Node.php",
        "line": 159,
        "function": "getMountPoint",
        "class": "OC\\Files\\Node\\Node",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/custom_apps/maps/lib/Hooks/FileHooks.php",
        "line": 179,
        "function": "getStorage",
        "class": "OC\\Files\\Node\\Node",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/custom_apps/maps/lib/Hooks/FileHooks.php",
        "line": 47,
        "function": "isUserNode",
        "class": "OCA\\Maps\\Hooks\\FileHooks",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "function": "OCA\\Maps\\Hooks\\{closure}",
        "class": "OCA\\Maps\\Hooks\\FileHooks",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/lib/private/Hooks/EmitterTrait.php",
        "line": 88,
        "function": "call_user_func_array",
        "args": [
          {
            "__class__": "Closure"
          },
          [
            "*** sensitive parameters replaced ***"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/Hooks/PublicEmitter.php",
        "line": 22,
        "function": "emit",
        "class": "OC\\Hooks\\BasicEmitter",
        "type": "->",
        "args": [
          "\\OC\\Files",
          "postWrite",
          [
            "*** sensitive parameters replaced ***"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/Node/Root.php",
        "line": 126,
        "function": "emit",
        "class": "OC\\Hooks\\PublicEmitter",
        "type": "->",
        "args": [
          "\\OC\\Files",
          "postWrite",
          [
            "*** sensitive parameters replaced ***"
          ]
        ]
      },
      {
        "function": "emit",
        "class": "OC\\Files\\Node\\Root",
        "type": "->",
        "args": [
          "\\OC\\Files",
          "postWrite",
          [
            "*** sensitive parameters replaced ***"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/Node/LazyFolder.php",
        "line": 64,
        "function": "call_user_func_array",
        "args": [
          [
            {
              "__class__": "OC\\Files\\Node\\Root"
            },
            "emit"
          ],
          [
            "\\OC\\Files",
            "postWrite",
            [
              "*** sensitive parameters replaced ***"
            ]
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/Node/LazyFolder.php",
        "line": 92,
        "function": "__call",
        "class": "OC\\Files\\Node\\LazyFolder",
        "type": "->",
        "args": [
          "emit",
          [
            "\\OC\\Files",
            "postWrite",
            [
              "*** sensitive parameters replaced ***"
            ]
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/Node/HookConnector.php",
        "line": 79,
        "function": "emit",
        "class": "OC\\Files\\Node\\LazyFolder",
        "type": "->",
        "args": [
          "\\OC\\Files",
          "postWrite",
          [
            "*** sensitive parameters replaced ***"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/legacy/OC_Hook.php",
        "line": 85,
        "function": "postWrite",
        "class": "OC\\Files\\Node\\HookConnector",
        "type": "->",
        "args": [
          {
            "run": true,
            "path": "/Google Drive/I got a space at the end "
          }
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/View.php",
        "line": 1321,
        "function": "emit",
        "class": "OC_Hook",
        "type": "::",
        "args": [
          "OC_Filesystem",
          "post_write",
          {
            "run": true,
            "path": "/Google Drive/I got a space at the end "
          }
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/View.php",
        "line": 1253,
        "function": "runHooks",
        "class": "OC\\Files\\View",
        "type": "->",
        "args": [
          [
            "create",
            "write"
          ],
          "/Google Drive/I got a space at the end ",
          true
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/View.php",
        "line": 211,
        "function": "basicOperation",
        "class": "OC\\Files\\View",
        "type": "->",
        "args": [
          "mkdir",
          "/[REDACTED]/files/Google Drive/I got a space at the end ",
          [
            "create",
            "write"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/Node/Folder.php",
        "line": 129,
        "function": "mkdir",
        "class": "OC\\Files\\View",
        "type": "->",
        "args": [
          "/[REDACTED]/files/Google Drive/I got a space at the end "
        ]
      },
      {
        "file": "/var/www/html/custom_apps/integration_google/lib/Service/GoogleDriveAPIService.php",
        "line": 544,
        "function": "newFolder",
        "class": "OC\\Files\\Node\\Folder",
        "type": "->",
        "args": [
          "I got a space at the end "
        ]
      },
      {
        "file": "/var/www/html/custom_apps/integration_google/lib/Service/GoogleDriveAPIService.php",
        "line": 290,
        "function": "createDirsUnder",
        "class": "OCA\\Google\\Service\\GoogleDriveAPIService",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/html/custom_apps/integration_google/lib/Service/GoogleDriveAPIService.php",
        "line": 188,
        "function": "importFiles",
        "class": "OCA\\Google\\Service\\GoogleDriveAPIService",
        "type": "->",
        "args": [
          "[REDACTED]",
          "/Google Drive",
          500000000,
          0,
          0,
          []
        ]
      },
      {
        "file": "/var/www/html/custom_apps/integration_google/lib/BackgroundJob/ImportDriveJob.php",
        "line": 36,
        "function": "importDriveJob",
        "class": "OCA\\Google\\Service\\GoogleDriveAPIService",
        "type": "->",
        "args": [
          "[REDACTED]"
        ]
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/Job.php",
        "line": 61,
        "function": "run",
        "class": "OCA\\Google\\BackgroundJob\\ImportDriveJob",
        "type": "->",
        "args": [
          {
            "user_id": "[REDACTED]"
          }
        ]
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/QueuedJob.php",
        "line": 43,
        "function": "start",
        "class": "OCP\\BackgroundJob\\Job",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\BackgroundJob\\JobList"
          }
        ]
      },
      {
        "file": "/var/www/html/lib/public/BackgroundJob/QueuedJob.php",
        "line": 29,
        "function": "start",
        "class": "OCP\\BackgroundJob\\QueuedJob",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\BackgroundJob\\JobList"
          }
        ]
      },
      {
        "file": "/var/www/html/cron.php",
        "line": 170,
        "function": "execute",
        "class": "OCP\\BackgroundJob\\QueuedJob",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\BackgroundJob\\JobList"
          }
        ]
      }
    ],
    "File": "/var/www/html/lib/private/Files/Node/Node.php",
    "Line": 90,
    "message": "",
    "exception": [],
    "CustomMessage": "Exception thrown: OCP\\Files\\NotFoundException"
  },
  "id": "[REDACTED]"
}
3. Job fails entirely (migration aborts)
{
  "reqId": "[REDACTED]",
  "level": 3,
  "time": "[REDACTED]",
  "remoteAddr": "",
  "user": "[REDACTED]",
  "app": "integration_google",
  "method": "",
  "url": "--",
  "message": "Google Drive import error: Unknown job failure. OCP\\Files\\NotFoundException in /var/www/html/lib/private/Files/Node/Node.php:90\nStack trace:\n#0 /var/www/html/lib/private/Files/Node/Node.php(359): OC\\Files\\Node\\Node->getFileInfo(false)\n#1 /var/www/html/lib/private/Files/Node/Node.php(159): OC\\Files\\Node\\Node->getMountPoint()\n#2 /var/www/html/custom_apps/maps/lib/Hooks/FileHooks.php(179): OC\\Files\\Node\\Node->getStorage()\n#3 /var/www/html/custom_apps/maps/lib/Hooks/FileHooks.php(47): OCA\\Maps\\Hooks\\FileHooks->isUserNode(Object(OC\\Files\\Node\\Folder))\n#4 [internal function]: OCA\\Maps\\Hooks\\FileHooks->OCA\\Maps\\Hooks\\{closure}(Object(OC\\Files\\Node\\Folder))\n#5 /var/www/html/lib/private/Hooks/EmitterTrait.php(88): call_user_func_array(Object(Closure), Array)\n#6 /var/www/html/lib/private/Hooks/PublicEmitter.php(22): OC\\Hooks\\BasicEmitter->emit('\\\\OC\\\\Files', 'postWrite', Array)\n#7 /var/www/html/lib/private/Files/Node/Root.php(126): OC\\Hooks\\PublicEmitter->emit('\\\\OC\\\\Files', 'postWrite', Array)\n#8 /var/www/html/lib/private/Files/Node/Node.php(110): OC\\Files\\Node\\Root->emit('\\\\OC\\\\Files', 'postWrite', Array)\n#9 /var/www/html/lib/private/Files/Node/Folder.php(134): OC\\Files\\Node\\Node->sendHooks(Array, Array)\n#10 /var/www/html/custom_apps/integration_google/lib/Service/GoogleDriveAPIService.php(544): OC\\Files\\Node\\Folder->newFolder('I got a space a...')\n#11 /var/www/html/custom_apps/integration_google/lib/Service/GoogleDriveAPIService.php(290): OCA\\Google\\Service\\GoogleDriveAPIService->createDirsUnder(Array, Object(OC\\Files\\Node\\Folder))\n#12 /var/www/html/custom_apps/integration_google/lib/Service/GoogleDriveAPIService.php(188): OCA\\Google\\Service\\GoogleDriveAPIService->importFiles('[REDACTED]', '/Google Drive', 500000000, 0, 0, Array)\n#13 /var/www/html/custom_apps/integration_google/lib/BackgroundJob/ImportDriveJob.php(36): OCA\\Google\\Service\\GoogleDriveAPIService->importDriveJob('[REDACTED]')\n#14 /var/www/html/lib/public/BackgroundJob/Job.php(61): OCA\\Google\\BackgroundJob\\ImportDriveJob->run(Array)\n#15 /var/www/html/lib/public/BackgroundJob/QueuedJob.php(43): OCP\\BackgroundJob\\Job->start(Object(OC\\BackgroundJob\\JobList))\n#16 /var/www/html/lib/public/BackgroundJob/QueuedJob.php(29): OCP\\BackgroundJob\\QueuedJob->start(Object(OC\\BackgroundJob\\JobList))\n#17 /var/www/html/cron.php(170): OCP\\BackgroundJob\\QueuedJob->execute(Object(OC\\BackgroundJob\\JobList))\n#18 {main}",
  "userAgent": "--",
  "version": "31.0.2.1",
  "data": {
    "app": "integration_google"
  },
  "id": "[REDACTED]"
}

Expected Behavior

Expected Behavior

  • Trailing spaces should be sanitized, as with files (e.g. replaced by "-")
  • Migration should skip problematic folders and continue with other files instead of the entire process failing

To Reproduce

To Reproduce

  1. On Google Drive or Google Photos, create a folder with a space at the end (e.g. "/I got a space at the end ")
  2. Start a data migration to Nextcloud using the Google integration app
  3. Migration will fail when processing that folder

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions