{"record":{"id":"eb111d31c7fcfc14","repo":"passbolt/passbolt_api","slug":"could-not-save-the-comment-please-try-again-later","errorCode":null,"errorMessage":"Could not save the comment, please try again later.","messagePattern":"Could not save the comment, please try again later\\.","errorType":"http","errorClass":"InternalErrorException","httpStatus":500,"severity":"critical","filePath":"src/Service/Comments/CommentsAddService.php","lineNumber":73,"sourceCode":"     * @param \\App\\Utility\\UserAccessControl $uac The user access control\n     * @param string $foreignKey The identifier of the resource to add a comment to\n     * @param array $data The comment data\n     * @return \\App\\Model\\Entity\\Comment $comment comment entity\n     * @throws \\Cake\\Http\\Exception\\InternalErrorException if the comment couldn't be saved\n     */\n    public function add(UserAccessControl $uac, string $foreignKey, array $data): Comment\n    {\n        if (!Validation::uuid($foreignKey)) {\n            throw new BadRequestException(__('The resource identifier should be a valid UUID.'));\n        }\n\n        $comment = $this->_buildAndValidateCommentEntity($uac, $foreignKey, $data);\n        $this->_handleValidationErrors($comment);\n\n        if (!$this->Comments->save($comment)) {\n            $this->_handleValidationErrors($comment);\n            $oops = __('Could not save the comment, please try again later.');\n            throw new InternalErrorException($oops);\n        }\n        $this->_notifyUsers($comment);\n\n        return $comment;\n    }\n\n    /**\n     * Manage validation errors.\n     *\n     * @param \\App\\Model\\Entity\\Comment $comment comment\n     * @throws \\Cake\\Http\\Exception\\BadRequestException\n     * @throws \\Cake\\Http\\Exception\\NotFoundException\n     * @return void\n     */\n    protected function _handleValidationErrors(Comment $comment): void\n    {\n        $errors = $comment->getErrors();\n        if (!empty($errors)) {","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Service/Comments/CommentsAddService.php#L55-L91","documentation":"CommentsAddService::add() throws this 500 when the Comments table save() returns false even after entity validation passed. It re-runs _handleValidationErrors first; reaching this error means save failed for a non-validation reason (persistence-layer problem), so the server reports a generic internal error and suggests retrying.","triggerScenarios":"Database connection failure, DB write error, transaction/lock issues, or a behavior/event listener aborting the save — occurring during POST of a comment whose entity validated fine.","commonSituations":"Database temporarily down or out of connections; disk full on the DB host; deadlock under concurrent writes; custom plugin event handlers throwing/altering the save result.","solutions":["Retry the request after a short delay — the message explicitly suggests a transient problem.","Check the database server health (connection, disk space, locks) and the passbolt error logs for the underlying DB exception.","Ensure no custom plugin listener on Model.beforeSave/afterSave is aborting comment saves."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Nothing caller-side prevents a server-side save failure; just confirm entity fields are valid first:\nif (!commentText?.trim()) throw new Error('content required');","typeGuard":null,"tryCatchPattern":"try { await addComment(id, data); }\ncatch (e) {\n  if (e.response?.status === 500 && /Could not save the comment/.test(e.response?.data?.message ?? '')) {\n    await delay(1000); return addComment(id, data); // one retry\n  }\n  throw e;\n}","preventionTips":["Retry once on this specific 500 before surfacing an error to the user","Monitor passbolt and database server logs for the root cause","Keep plugin listeners on comment save events healthy"],"tags":["persistence","database","http-500"],"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"}