{"record":{"id":"b3862c5e5b9b2894","repo":"passbolt/passbolt_api","slug":"could-not-save-the-folder-relation-history","errorCode":null,"errorMessage":"Could not save the folder relation history.","messagePattern":"Could not save the folder relation history\\.","errorType":"http","errorClass":"Cake\\Http\\Exception\\InternalErrorException","httpStatus":500,"severity":"error","filePath":"plugins/PassboltCe/Folders/src/Model/Table/FoldersRelationsHistoryTable.php","lineNumber":173,"sourceCode":"     *\n     * @param array $data the data\n     * @return \\Passbolt\\Folders\\Model\\Entity\\FoldersRelation\n     * @throws \\App\\Error\\Exception\\ValidationException\n     * @throws \\Cake\\Http\\Exception\\InternalErrorException\n     */\n    public function create(array $data): FoldersRelation\n    {\n        // Check validation rules.\n        $folderRelationHistory = $this->buildEntity($data);\n        if ($folderRelationHistory->getErrors()) {\n            $msg = __('Could not validate folders relations history data.');\n            throw new ValidationException($msg, $folderRelationHistory, $this);\n        }\n        $folderRelationHistory = $this->save($folderRelationHistory);\n\n        // Check for errors while saving.\n        if (!$folderRelationHistory) {\n            throw new InternalErrorException('Could not save the folder relation history.');\n        }\n\n        // Check for validation errors. (associated models too).\n        if ($folderRelationHistory->getErrors()) {\n            $msg = __('Could not validate folders relations history data.');\n            throw new ValidationException($msg, $folderRelationHistory, $this);\n        }\n\n        return $folderRelationHistory;\n    }\n}\n","sourceCodeStart":155,"sourceCodeEnd":185,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltCe/Folders/src/Model/Table/FoldersRelationsHistoryTable.php#L155-L185","documentation":"Thrown by FoldersRelationsHistoryTable::create() when save() returns false, i.e. the entity passed validation but could not be persisted (InternalErrorException). This indicates a persistence-level failure rather than invalid input.","triggerScenarios":"save() failing due to database constraint violations (duplicate/missing referenced rows), database connection problems, or transaction/lock issues while writing the folders_relations_history row.","commonSituations":"Race conditions where the referenced folder or user was deleted between validation and save; database connectivity outages; FK constraint failures from inconsistent relation history data.","solutions":["Check the previous exception and database error logs to identify the save failure cause.","Verify database connectivity and that migrations for the folders plugin are up to date.","Ensure referenced entities (folder, user) still exist and the relation does not violate constraints.","Retry the operation; if it recurs, run integrity cleanup on folders_relations data."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { $table->create($data); } catch (InternalErrorException $e) { log_error($e->getPrevious()); /* retry or alert */ }","preventionTips":["Monitor database health/locks around relation writes","Keep migrations up to date to avoid constraint mismatches","Clean up orphaned folders_relations rows periodically"],"tags":["database","save-failure","folders"],"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"}