{"record":{"id":"3fa41b57b8d8ffd6","repo":"passbolt/passbolt_api","slug":"could-not-save-the-directory-entry","errorCode":null,"errorMessage":"Could not save the directory entry.","messagePattern":"Could not save the directory entry\\.","errorType":"http","errorClass":"InternalErrorException","httpStatus":500,"severity":"critical","filePath":"plugins/PassboltEe/DirectorySync/src/Model/Table/DirectoryEntriesTable.php","lineNumber":238,"sourceCode":"     */\n    public function create(array $data): bool|DirectoryEntry\n    {\n        // Check validation rules.\n        $directoryEntry = $this->buildEntityFromData($data);\n        if (!empty($directoryEntry ->getErrors())) {\n            throw new ValidationException(__('Could not validate directory entry data.'), $directoryEntry, $this);\n        }\n\n        $de = $this->save($directoryEntry);\n\n        // Check for validation errors. (associated models too).\n        if (!empty($directoryEntry->getErrors())) {\n            throw new ValidationException(__('Could not validate directory entry data.'), $directoryEntry, $this);\n        }\n\n        // Check for errors while saving.\n        if (!$de) {\n            throw new InternalErrorException('Could not save the directory entry.');\n        }\n\n        return $de;\n    }\n\n    /**\n     * Find a directory entries if it exist or create one\n     * Will update the name if it changed in the directory (example: DN changed)\n     *\n     * @param array $data data\n     * @param string $model model\n     * @return \\Passbolt\\DirectorySync\\Model\\Entity\\DirectoryEntry|array|bool\n     */\n    public function updateOrCreate(array $data, string $model): array|bool|DirectoryEntry\n    {\n        try {\n            return $this->getConnection()->transactional(\n                function () use ($data, $model): DirectoryEntry|bool {","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/DirectorySync/src/Model/Table/DirectoryEntriesTable.php#L220-L256","documentation":"InternalErrorException thrown by DirectoryEntriesTable::create() when save() returns falsy and no validation errors are present — an unexpected persistence failure (e.g. database constraint violation, connection issue) not attributable to validation.","triggerScenarios":"updateOrCreate() -> create() where $this->save($directoryEntry) returns false with a clean entity: DB write failure, constraint violation, table lock, or connection loss during sync.","commonSituations":"Database out of disk space or read-only replica; MySQL/Postgres constraint from stale migrations; long-running syncs hitting connection timeouts; locking contention from concurrent sync jobs.","solutions":["Check database server logs for the underlying write error at the time of the sync","Run migrations to confirm the directory_entries schema matches the code","Verify DB disk space and connection limits","Retry the sync once transient DB issues are resolved"],"exampleFix":"null","handlingStrategy":"retry","validationCode":"// confirm DB connectivity before sync\n$connection = \\Cake\\Datasource\\ConnectionFactoryLocator::get()->get();\n$connection->execute('SELECT 1'); // throws early if DB is down","typeGuard":"null","tryCatchPattern":"try {\n    $entriesTable->create($data);\n} catch (InternalErrorException $e) {\n    // no validation errors: persistence failed; check DB logs then retry\n    $this->log('Directory entry save failed without validation errors', 'error');\n    retryWithBackoff(fn() => $entriesTable->create($data), 2);\n}","preventionTips":["Monitor database disk space and connection limits","Keep migrations current so constraints match the code","Avoid overlapping long sync jobs that hold locks","Alert on DB write errors in logs/error.log"],"tags":["database","directory-sync","internal-error","write-failure"],"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"}