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

  1. Confirm the comment id exists in the comments table for the connected database
  2. Refresh the client's comment list before retrying the update
  3. Handle 404 gracefully in the client (remove the stale comment from UI)
  4. 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

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


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)