passbolt/passbolt_api · error · NotFoundException
Could not find comments for the requested model.
Error message
Could not find comments for the requested model.
What it means
Passbolt throws this NotFoundException when findViewForeignComments raises RecordNotFoundException, i.e. the target record for the given foreign model/key does not exist (or the user has no visibility of it). This maps to a 404 for the comments listing request.
Solutions
- Verify the target resource exists and is visible to the current user
- Refresh the resource list and retry with a valid id
- Handle the 404 in the client by removing stale references
Example fix
// before
$service->view($userId, 'Resource', $deletedResourceId);
// after
try { $comments = $service->view($userId, 'Resource', $resourceId); }
catch (NotFoundException $e) { /* resource gone: clear stale state */ } Defensive patterns
Strategy: try-catch
Validate before calling
$visible = $resourcesTable->findVisible($userId)->where(['id' => $foreignKey])->count() > 0;
Try / catch
try { $comments = $service->view($userId, $model, $foreignKey); } catch (NotFoundException $e) { /* resource missing/inaccessible: clear stale state */ } Prevention
- Re-sync resource lists before requesting comments
- Treat 404 as 'resource gone', not a bug
- Check user permissions when ids come from shared links
When it happens
Trigger: Requesting comments for a resource UUID that does not exist or was deleted; referencing a foreign key from another environment's database.
Common situations: Deleted resources still referenced in the UI; stale bookmarks/links; cross-environment id reuse in tests.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- The comment does not exist.
- 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/a758ea90385dc60a.
Report an issue: GitHub.
Appendix: source
Thrown at src/Service/Comments/CommentsViewService.php:80
// Check model sanity.
if (!in_array($foreignModelName, CommentsTable::ALLOWED_FOREIGN_MODELS)) {
throw new BadRequestException('Invalid model name');
}
// Check uuid sanity.
if (!Validation::uuid($foreignKey)) {
throw new BadRequestException('Invalid id');
}
try {
$comments = $this->Comments->findViewForeignComments(
$userId,
$foreignModelName,
$foreignKey,
$options
);
} catch (RecordNotFoundException $e) {
throw new NotFoundException(__('Could not find comments for the requested model.'));
}
return $comments;
}
}
View on GitHub (pinned to 31c1bbc10f)