deck icon indicating copy to clipboard operation
deck copied to clipboard

Import json with occ command fails

Open kromuchi opened this issue 6 months ago • 1 comments

I am trying to import a DECK json from an previously exported deck via occ. As described in the user documentation, i created a config file and put it together with the json file in the nextcloud root folder (where occ is). As I share the decks only with a single user and both users have the same name on the old and the new nextcloud instance - so the config file looks like this:

{
    "owner": "testuser",
    "uidRelation": {
        "testuser": "testuser",
        "otheruser": "otheruser"
    }
}

The import fails with the following error message (stack trace):

$ occ deck:import testuser-deck-export.json
Starting import...
Please provide a valid data json file: testuser-deck-export-config.json
An unhandled exception has been thrown:
TypeError: OCA\Deck\Service\Importer\BoardImportService::setData(): Argument #1 ($data) must be of type stdClass, string given, called in /var/www/.../nextcloud/apps/deck/lib/Service/Importer/BoardImportCommandService.php on line 206 and defined in /var/www/.../nextcloud/apps/deck/lib/Service/Importer/BoardImportService.php:392
Stack trace:
#0 /var/www/.../nextcloud/apps/deck/lib/Service/Importer/BoardImportCommandService.php(206): OCA\Deck\Service\Importer\BoardImportService->setData('testuser')
#1 /var/www/.../nextcloud/apps/deck/lib/Command/BoardImport.php(76): OCA\Deck\Service\Importer\BoardImportCommandService->import()
#2 /var/www/.../nextcloud/3rdparty/symfony/console/Command/Command.php(326): OCA\Deck\Command\BoardImport->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /var/www/.../nextcloud/3rdparty/symfony/console/Application.php(1078): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /var/www/.../nextcloud/3rdparty/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand(Object(OCA\Deck\Command\BoardImport), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 /var/www/.../nextcloud/3rdparty/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /var/www/.../nextcloud/lib/private/Console/Application.php(187): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /var/www/.../nextcloud/console.php(87): OC\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput))
#8 /var/www/.../nextcloud/occ(33): require_once('/var/www/...')

The nextcloud log says

{"reqId":"BS199YbUfIAiUyCrhL1y","level":3,"time":"2025-05-31T21:24:49+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"file_get_contents(data.json): Failed to open stream: No such file or directory at /var/www/.../nextcloud/apps/deck/lib/Service/Importer/BoardImportCommandService.php#150","userAgent":"--","version":"31.0.5.1","data":{"app":"PHP"}}

Am I doing something wrong or is this a bug?

Server details

Database: mariadb PHP version: 8.3.19 Nextcloud version: 31.0.5 Deck: 1.15.1

Logs

Nextcloud log (data/nextcloud.log)

{"reqId":"BS199YbUfIAiUyCrhL1y","level":3,"time":"2025-05-31T21:24:49+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"file_get_contents(data.json): Failed to open stream: No such file or directory at /var/www/.../nextcloud/apps/deck/lib/Service/Importer/BoardImportCommandService.php#150","userAgent":"--","version":"31.0.5.1","data":{"app":"PHP"}}

kromuchi avatar May 31 '25 21:05 kromuchi

@kromuchi It seems that the executing user does not have permission to access the data file "testuser-deck-export.json." As a result, the prompt "Please provide a valid data JSON file:" was displayed to request the correct data file. Therefore, please ensure that the executing user has the necessary permissions to read the data file. The correct command should be: occ deck:import --config testuser-deck-export-config.json testuser-deck-export.json

luka-nextcloud avatar Jun 16 '25 10:06 luka-nextcloud

Thank you, the bad permissions could be fixed. Afterwards, there was another error (please provide valid data json file) - this was caused by two unexpected lines at the beginning of the exported data config file:

The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see https://www.php.net/manual/en/book.pcntl.php
Additionally the function 'pcntl_signal' and 'pcntl_signal_dispatch' need to be enabled in your php.ini.

After removing those lines, the import function worked out.

Note that the files must be relative to occ command (which is probably obvious but due to the many errors I was not sure whether I had the correct location / directory)

kromuchi avatar Jun 22 '25 21:06 kromuchi