{"record":{"id":"b6593c3d1a582cf3","repo":"n8n-io/n8n","slug":"error-message-b6593c","errorCode":null,"errorMessage":"error.message","messagePattern":"error\\.message","errorType":"http","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"packages/cli/src/controller.registry.ts","lineNumber":253,"sourceCode":"\n\tprivate createScopedMiddleware(accessScope: AccessScope): RequestHandler {\n\t\treturn async (req, res, next) => {\n\t\t\tif (!isAuthenticatedRequest(req)) throw new UnauthenticatedError();\n\t\t\tif (!req.user) throw new UnauthenticatedError();\n\n\t\t\tconst { scope, globalOnly } = accessScope;\n\n\t\t\ttry {\n\t\t\t\tif (!(await userHasScopes(req.user, [scope], globalOnly, req.params))) {\n\t\t\t\t\tres.status(403).json({\n\t\t\t\t\t\tstatus: 'error',\n\t\t\t\t\t\tmessage: RESPONSE_ERROR_MESSAGES.MISSING_SCOPE,\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof NotFoundError) {\n\t\t\t\t\tres.status(404).json({ status: 'error', message: error.message });\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tnext();\n\t\t};\n\t}\n}\n","sourceCodeStart":235,"sourceCodeEnd":263,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/controller.registry.ts#L235-L263","documentation":"Returned as a 404 JSON response by `createScopedMiddleware` when `userHasScopes` throws a `NotFoundError` (e.g. the project referenced by `req.params` does not exist or the user has no relation to it). The caught error's `.message` is echoed verbatim in the response body. Any other thrown error is re-thrown to the global handler.","triggerScenarios":"Calling a project-scoped endpoint like `/rest/projects/:projectId/...` where `:projectId` does not exist or is not shared with the user; a deleted project referenced in a URL.","commonSituations":"Stale project ID in a bookmarked URL; project was deleted between two client calls; user was removed from the project.","solutions":["Verify the resource ID in the URL exists and is accessible to the user.","Refresh the client-side project list and use a current ID.","If the project should exist, check the DB and the user's project membership."],"exampleFix":"// before\nGET /rest/projects/old-or-deleted-id/credentials\n// after\nGET /rest/projects/<current-shared-project-id>/credentials","handlingStrategy":"validation","validationCode":"const project = await projectRepo.findOneBy({ id: projectId });\nif (!project) throw new Error(`Project ${projectId} not found or not shared with user`);","typeGuard":null,"tryCatchPattern":"try { await api.get(`/projects/${id}/creds`); } catch (e) { if (e.response?.status === 404) { await refreshProjectList(); } else throw e; }","preventionTips":["Cache the active project list client-side and invalidate on deletes.","Avoid hard-coding project IDs in URLs; source them from the list endpoint."],"tags":["api","rbac","rest","not-found","user-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}