passbolt/passbolt_api · error · NotFoundException
The comment does not exist.
Error message
The comment does not exist.
What it means
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.
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
Example fix
// before
$service->update($userId, $possiblyDeletedId, $data);
// after
try { $service->update($userId, $possiblyDeletedId, $data); }
catch (NotFoundException $e) { /* refresh list / notify user */ } Defensive patterns
Strategy: try-catch
Validate before calling
$exists = $commentsTable->exists(['id' => $commentId]);
Try / catch
try { $service->update($userId, $commentId, $data); } catch (NotFoundException $e) { /* refresh comment list, drop stale item */ } Prevention
- Refresh comment lists after deletions
- Confirm DB/environment configuration matches where the comment was created
- Handle 404 as 'stale reference' in clients
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- Could not find comments for the requested model.
- AssociatedRecordExists
- Could not delete comment.
- Could not validate comment data.
- Could not validate comment data.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/1927301c14534192.
Report an issue: GitHub.
Appendix: source
Thrown at src/Service/Comments/CommentsUpdateService.php:107
}
throw new ValidationException(__('Could not validate comment data.'), $comment, $this->Comments);
}
}
/**
* Patch and validate comment entity from user input.
*
* @param string $userId The currently logged in user ID
* @param string $commentId The comment ID
* @param string $requestDataContent The comment 'content' data
* @return \App\Model\Entity\Comment $comment comment entity
*/
protected function _patchAndValidateCommentEntity(string $userId, string $commentId, string $requestDataContent): Comment // phpcs:ignore
{
try {
$comment = $this->Comments->get($commentId);
} catch (RecordNotFoundException $e) {
throw new NotFoundException(__('The comment does not exist.'));
}
/**
* @var \App\Model\Entity\Comment $comment
*/
$comment = $this->Comments->patchEntity(
$comment,
[
'content' => $requestDataContent,
'modified_by' => $userId,
],
[
'accessibleFields' => [
'content' => true,
'modified_by' => true,
],
]
);View on GitHub (pinned to 31c1bbc10f)