{"record":{"id":"1927301c14534192","repo":"passbolt/passbolt_api","slug":"the-comment-does-not-exist-commentsupdateservice","errorCode":null,"errorMessage":"The comment does not exist.","messagePattern":"The comment does not exist\\.","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"src/Service/Comments/CommentsUpdateService.php","lineNumber":107,"sourceCode":"            }\n            throw new ValidationException(__('Could not validate comment data.'), $comment, $this->Comments);\n        }\n    }\n\n    /**\n     * Patch and validate comment entity from user input.\n     *\n     * @param string $userId The currently logged in user ID\n     * @param string $commentId The comment ID\n     * @param string $requestDataContent The comment 'content' data\n     * @return \\App\\Model\\Entity\\Comment $comment comment entity\n     */\n    protected function _patchAndValidateCommentEntity(string $userId, string $commentId, string $requestDataContent): Comment // phpcs:ignore\n    {\n        try {\n            $comment = $this->Comments->get($commentId);\n        } catch (RecordNotFoundException $e) {\n            throw new NotFoundException(__('The comment does not exist.'));\n        }\n\n        /**\n         * @var \\App\\Model\\Entity\\Comment $comment\n         */\n        $comment = $this->Comments->patchEntity(\n            $comment,\n            [\n                'content' => $requestDataContent,\n                'modified_by' => $userId,\n            ],\n            [\n                'accessibleFields' => [\n                    'content' => true,\n                    'modified_by' => true,\n                ],\n            ]\n        );","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Service/Comments/CommentsUpdateService.php#L89-L125","documentation":"Passbolt throws this NotFoundException when CommentsTable::get() cannot find a comment for the given id, i.e. RecordNotFoundException is caught and translated into a 404-style error. The comment either never existed or was deleted.","triggerScenarios":"update() is called with a well-formed UUID that matches no row in the comments table; the comment was deleted before the update arrived; a different environment/database is queried than the one that created the comment.","commonSituations":"Stale client cache referencing deleted comments; pointing the app at another database (dev vs prod); concurrent deletion by another user; soft-deleted or purged comments.","solutions":["Confirm the comment id exists in the comments table for the connected database","Refresh the client's comment list before retrying the update","Handle 404 gracefully in the client (remove the stale comment from UI)","Check environment/database configuration to ensure you target the intended DB"],"exampleFix":"// before\n$service->update($userId, $possiblyDeletedId, $data);\n// after\ntry { $service->update($userId, $possiblyDeletedId, $data); }\ncatch (NotFoundException $e) { /* refresh list / notify user */ }","handlingStrategy":"try-catch","validationCode":"$exists = $commentsTable->exists(['id' => $commentId]);","typeGuard":null,"tryCatchPattern":"try { $service->update($userId, $commentId, $data); } catch (NotFoundException $e) { /* refresh comment list, drop stale item */ }","preventionTips":["Refresh comment lists after deletions","Confirm DB/environment configuration matches where the comment was created","Handle 404 as 'stale reference' in clients"],"tags":["not-found","comments","record"],"backgroundTag":"record-not-found","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"}