passbolt/passbolt_api · error · NotFoundException
The resource does not exist.
Error message
The resource does not exist.
What it means
Raised inside CommentsAddService::_handleValidationErrors() when the comment entity failed validation specifically because the referenced resource fails the foreign_key rules: the resource does not exist, is soft-deleted, or the user has no access to it. It is mapped to 404 rather than 400 so it doesn't leak whether the resource exists.
Solutions
- Refresh the resource list and confirm the resource id still exists and is visible to the current user.
- Re-share the resource/folder with the user if access was revoked.
- Check you are calling the correct passbolt instance (environment mismatch produces 404s for valid-looking ids).
Example fix
// before addComment(deletedResourceId, 'text') // after const resource = await getResource(id); // 404 surfaces here, before commenting if (!resource) return; await addComment(resource.id, 'text');
Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the resource is reachable before commenting:
const resource = await fetch(`${baseUrl}/resources/${resourceId}`).then(r => { if (!r.ok) throw new Error('resource inaccessible'); return r.json(); }); Try / catch
try { await addComment(resourceId, data); }
catch (e) { if (e.response?.status === 404) { await refreshResourceList(); notifyUser('Resource no longer available'); } else throw e; } Prevention
- Refresh resource lists before operations on cached ids
- Re-check folder/resource share permissions after permission changes
- Ensure clients point at the intended environment
When it happens
Trigger: POSTing a comment to a resource UUID that: was deleted (soft delete), was never created, belongs to a deleted/shared folder the user cannot access, or is in a resource the calling user lacks permission on.
Common situations: Client caching a resource id that was deleted by another user; comments on resources shared via a folder that lost share permissions; using an id from a different passbolt instance/environment (staging vs prod).
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- The comment does not exist.
- The commented object type does not exist.
- The resource does not exist.
- The resource does not exist.
- Cannot delete group user.
AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17).
Data as JSON: /api/errors/fe17eef7ca18aee1.
Report an issue: GitHub.
Appendix: source
Thrown at src/Service/Comments/CommentsAddService.php:100
*
* @param \App\Model\Entity\Comment $comment comment
* @throws \Cake\Http\Exception\BadRequestException
* @throws \Cake\Http\Exception\NotFoundException
* @return void
*/
protected function _handleValidationErrors(Comment $comment): void
{
$errors = $comment->getErrors();
if (!empty($errors)) {
if (
!empty($errors['foreign_key']) &&
(
!empty($errors['foreign_key']['resource_exists']) ||
!empty($errors['foreign_key']['resource_is_soft_deleted']) ||
!empty($errors['foreign_key']['has_resource_access'])
)
) {
throw new NotFoundException(__('The resource does not exist.'));
}
throw new BadRequestException(__('Could not validate comment data.'));
}
}
/**
* Build and validate comment entity from user input.
*
* @param \App\Utility\UserAccessControl $uac The user access control
* @param string $foreignKey The identifier of the instance the comment belongs to.
* @param array $data The comment data
* @return \App\Model\Entity\Comment $comment comment entity
*/
protected function _buildAndValidateCommentEntity(UserAccessControl $uac, string $foreignKey, array $data): Comment
{
// Build entity and perform basic check.
/**
* @var \App\Model\Entity\Comment $commentView on GitHub (pinned to 31c1bbc10f)