{"record":{"id":"a47ac33f7ef2ab6c","repo":"passbolt/passbolt_api","slug":"data-for-s-cannot-be-imported","errorCode":null,"errorMessage":"Data for %s cannot be imported","messagePattern":"Data for (.+?) cannot be imported","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/PassboltDev/TestData/src/Lib/DataCommand.php","lineNumber":97,"sourceCode":"        // Console IO used by the Save Strategies\n        $this->io = $io;\n\n        // $conn = \\Cake\\Datasource\\ConnectionManager::get('default');\n        // $conn->logQueries(true);\n\n        // Insert the data in the db.\n        $data = $this->getData();\n        try {\n            $this->save($data);\n            // old fashion way (can be useful for debugging)\n            // return $this->saveOneByOne();\n            $endTime = time();\n            $dtF = new DateTime(\"@$startTime\");\n            $dtT = new DateTime(\"@$endTime\");\n            $diff = $dtF->diff($dtT)->format('%im %ss');\n            $io->out('Data for entity \"' . $this->entityName . '\" inserted (' . count($data) . ') in ' . $diff);\n        } catch (Exception $e) {\n            $io->err(sprintf('Data for %s cannot be imported', $this->entityName));\n            $io->warning($e->getMessage());\n\n            return static::CODE_ERROR;\n        }\n\n        return static::CODE_SUCCESS;\n    }\n\n    /**\n     * Display the progress bar\n     *\n     * @param int $total Number total of tasks\n     * @return \\Cake\\Console\\Helper\\ProgressHelper|null\n     */\n    public function displayProgressBar(int $total): ?ProgressHelper\n    {\n        $progress = null;\n","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltDev/TestData/src/Lib/DataCommand.php#L79-L115","documentation":"DataCommand is the base class for passbolt test-data seed commands (in the TestData dev plugin). Its execute() wraps the whole data import in a try/catch; when any Exception escapes the import it prints a generic per-entity message 'Data for <entity> cannot be imported' plus the exception text as a warning, and returns CODE_ERROR. This is a top-level catch-all for seeding failures.","triggerScenarios":"Running a test-data seeding command (e.g. `passbolt testdata users|groups|resources ...`) when the entity-specific insert logic throws — database insert failures, missing tables/migrations, validation exceptions bubbling from save strategies.","commonSituations":"Seeding test data into an environment whose schema is out of date (migrations not run); database connection problems; seeding entities that violate constraints (duplicate emails/usernames).","solutions":["Check the warning line printed below the error for the real exception message.","Run pending migrations: `ddev refresh` or `bin/cake migrations migrate`.","Verify database connectivity and credentials in config/app.php.","Re-run with a smaller count to isolate the offending row.","Fix duplicates/conflicting data (e.g. existing users with the same username) then retry."],"exampleFix":"// before\n} catch (Exception $e) {\n    $io->err(sprintf('Data for %s cannot be imported', $this->entityName));\n// after\n} catch (Exception $e) {\n    $io->err(sprintf('Data for %s cannot be imported: %s', $this->entityName, $e->getMessage()));","handlingStrategy":"try-catch","validationCode":"// before seeding\n$connection = \\Cake\\Datasource\\ConnectionManager::get('default');\n$connection->execute('SELECT 1'); // connectivity check\n$status = (new \\Migrations\\MigrationManager($connection))->status ?? null; // ensure migrations applied via bin/cake migrations status","typeGuard":null,"tryCatchPattern":"try {\n    $command->run($args, $io);\n} catch (\\Exception $e) {\n    $io->error('Seeding failed: ' . $e->getMessage());\n    // inspect $e->getPrevious() for the root DB error\n}","preventionTips":["Run all migrations before seeding test data.","Clean the database (or use fresh fixtures) before re-running seed commands to avoid duplicates.","Verify DB connectivity before long seed runs.","Seed in small batches to isolate failing rows."],"tags":["cli","test-data","seeding","database"],"backgroundTag":"database-write-failed","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}