n8n-io/n8n · warning
error.message
Error message
error.message
What it means
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.
Source
Thrown at packages/cli/src/controller.registry.ts:253
private createScopedMiddleware(accessScope: AccessScope): RequestHandler {
return async (req, res, next) => {
if (!isAuthenticatedRequest(req)) throw new UnauthenticatedError();
if (!req.user) throw new UnauthenticatedError();
const { scope, globalOnly } = accessScope;
try {
if (!(await userHasScopes(req.user, [scope], globalOnly, req.params))) {
res.status(403).json({
status: 'error',
message: RESPONSE_ERROR_MESSAGES.MISSING_SCOPE,
});
return;
}
} catch (error) {
if (error instanceof NotFoundError) {
res.status(404).json({ status: 'error', message: error.message });
return;
}
throw error;
}
next();
};
}
}
View on GitHub (pinned to 5ac6606e81)
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.
Example fix
// before GET /rest/projects/old-or-deleted-id/credentials // after GET /rest/projects/<current-shared-project-id>/credentials
Defensive patterns
Strategy: validation
Validate before calling
const project = await projectRepo.findOneBy({ id: projectId });
if (!project) throw new Error(`Project ${projectId} not found or not shared with user`); Try / catch
try { await api.get(`/projects/${id}/creds`); } catch (e) { if (e.response?.status === 404) { await refreshProjectList(); } else throw e; } Prevention
- Cache the active project list client-side and invalidate on deletes.
- Avoid hard-coding project IDs in URLs; source them from the list endpoint.
When it happens
Trigger: 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.
Common situations: Stale project ID in a bookmarked URL; project was deleted between two client calls; user was removed from the project.
Related errors
- User is missing a scope required to perform this action
- output.error.errors[0]
- Plan lacks license for this feature
- 401
- Role not found
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/b6593c3d1a582cf3.
Report an issue: GitHub.