passbolt/passbolt_api · error · NotFoundException

The comment does not exist.

Error message

The comment does not exist.

What it means

CommentsDeleteService::delete() catches RecordNotFoundException from CommentsTable::get($id) and converts it to a 404 NotFoundException. This means no comment row exists with the given UUID — the id was well-formed but references nothing.

Solutions

  1. Refetch the comment list to confirm the comment still exists before deleting.
  2. Treat HTTP 404 as success in idempotent delete flows (the target state — comment gone — is already achieved).
  3. Verify the id against the database if you believe the comment should exist.

Example fix

// before
await api.delete(`/comments/${id}`); // crashes on 404
// after
try { await api.delete(`/comments/${id}`); } catch (e) { if (e.status !== 404) throw e; } // idempotent
Defensive patterns

Strategy: try-catch

Validate before calling

// Confirm the comment is still listed before deleting:
const stillExists = (await listComments(resourceId)).some(c => c.id === commentId);

Try / catch

try { await deleteComment(id, userId); }
catch (e) { if (e.response?.status === 404) { removeFromLocalCache(id); } else throw e; } // treat as already deleted

Prevention

When it happens

Trigger: DELETE /comments/{uuid} where the comment was already deleted, the id was mistyped as a different UUID, or the id comes from another environment/database.

Common situations: Double-delete races (two UI tabs deleting the same comment); stale client caches listing already-removed comments; ids copied from API logs of a different instance.

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


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/a7e611063b0cda41. Report an issue: GitHub.

Appendix: source

Thrown at src/Service/Comments/CommentsDeleteService.php:69

     */
    public function delete(string $id, ?string $userId = null): void
    {
        // Check request sanity
        if (!Validation::uuid($id)) {
            throw new BadRequestException(__('The comment id is not valid.'));
        }
        if (is_null($userId) || empty($userId)) {
            throw new BadRequestException(__('The comment userId is not valid.'));
        }

        // Retrieve the comment.
        try {
            /**
             * @var \App\Model\Entity\Comment $comment
             */
            $comment = $this->Comments->get($id);
        } catch (RecordNotFoundException $e) {
            throw new NotFoundException(__('The comment does not exist.'));
        }

        // Delete the comment.
        $this->Comments->delete($comment, ['Comments.user_id' => $userId]);
        $this->_handleDeleteErrors($comment);
    }

    /**
     * Manage delete errors
     *
     * @param \App\Model\Entity\Comment $comment comment
     * @return void
     */
    private function _handleDeleteErrors(Comment $comment): void
    {
        $errors = $comment->getErrors();
        if (!empty($errors)) {
            if (isset($errors['user_id']['is_owner'])) {

View on GitHub (pinned to 31c1bbc10f)