{"record":{"id":"a758ea90385dc60a","repo":"passbolt/passbolt_api","slug":"could-not-find-comments-for-the-requested-model","errorCode":null,"errorMessage":"Could not find comments for the requested model.","messagePattern":"Could not find comments for the requested model\\.","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"src/Service/Comments/CommentsViewService.php","lineNumber":80,"sourceCode":"        // Check model sanity.\n        if (!in_array($foreignModelName, CommentsTable::ALLOWED_FOREIGN_MODELS)) {\n            throw new BadRequestException('Invalid model name');\n        }\n\n        // Check uuid sanity.\n        if (!Validation::uuid($foreignKey)) {\n            throw new BadRequestException('Invalid id');\n        }\n\n        try {\n            $comments = $this->Comments->findViewForeignComments(\n                $userId,\n                $foreignModelName,\n                $foreignKey,\n                $options\n            );\n        } catch (RecordNotFoundException $e) {\n            throw new NotFoundException(__('Could not find comments for the requested model.'));\n        }\n\n        return $comments;\n    }\n}\n","sourceCodeStart":62,"sourceCodeEnd":86,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/src/Service/Comments/CommentsViewService.php#L62-L86","documentation":"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.","triggerScenarios":"Requesting comments for a resource UUID that does not exist or was deleted; referencing a foreign key from another environment's database.","commonSituations":"Deleted resources still referenced in the UI; stale bookmarks/links; cross-environment id reuse in tests.","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"],"exampleFix":"// before\n$service->view($userId, 'Resource', $deletedResourceId);\n// after\ntry { $comments = $service->view($userId, 'Resource', $resourceId); }\ncatch (NotFoundException $e) { /* resource gone: clear stale state */ }","handlingStrategy":"try-catch","validationCode":"$visible = $resourcesTable->findVisible($userId)->where(['id' => $foreignKey])->count() > 0;","typeGuard":null,"tryCatchPattern":"try { $comments = $service->view($userId, $model, $foreignKey); } catch (NotFoundException $e) { /* resource missing/inaccessible: clear stale state */ }","preventionTips":["Re-sync resource lists before requesting comments","Treat 404 as 'resource gone', not a bug","Check user permissions when ids come from shared links"],"tags":["not-found","comments","record"],"backgroundTag":"resource-not-found","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}