Mintplex-Labs/anything-llm · error
User not found
Error message
User not found
What it means
With a valid multi-user temp token, validRegistrationToken loads User.get({ id: Number(tempTokenData.userId) }); if no users row matches, it returns 400 { error: 'User not found' }. The token is structurally valid but points at an account that no longer exists.
Source
Thrown at server/endpoints/mobile/middleware/index.js:77
.json({ error: "Registration token is required" });
const tempTokenData = MobileDevice.tempToken(tempToken);
if (!tempTokenData)
return response
.status(400)
.json({ error: "Invalid or expired registration token" });
// If in multi-user mode, we need to validate the user id
// associated exists, is not banned and then associate with locals so we can reuse it later.
// If not in multi-user mode then simply having a valid token is enough.
const multiUserMode = await SystemSettings.isMultiUserMode();
if (multiUserMode) {
if (!tempTokenData.userId)
return response
.status(400)
.json({ error: "User id not found in registration token" });
const user = await User.get({ id: Number(tempTokenData.userId) });
if (!user) return response.status(400).json({ error: "User not found" });
if (user.suspended)
return response
.status(400)
.json({ error: "User is suspended - cannot register device" });
response.locals.user = user;
}
next();
} catch (error) {
console.error("validRegistrationToken:error", error);
response.status(500).json({
error: "Invalid middleware response from validRegistrationToken",
});
}
}
module.exports = {
validDeviceToken,View on GitHub (pinned to 3aec848f28)
Solutions
- Have an existing user/admin generate new connect-info and re-register against it
- Confirm the intended user still exists under admin > users before handing out pairing codes
- Discard old pairing URLs after user deletions
Defensive patterns
Strategy: retry
Try / catch
try {
await register(tempToken);
} catch (e) {
if (e.status === 400 && e.body?.error === 'User not found') {
const fresh = await fetchConnectInfoAs(activeUser); // owner was deleted
return register(fresh);
}
throw e;
} Prevention
- Invalidate outstanding pairing URLs when deleting users
- Generate connect-info from an account verified to still exist
- Pair promptly after generating codes
When it happens
Trigger: The account that generated the connect-info QR was deleted before the device finished registering; DB was reset wiping users while the in-memory token Map (or a copied URL) survived; token hand-edited with an arbitrary userId.
Common situations: Admin offboarded/deleted a user mid pairing; long-lived pairing URLs shared then used after cleanup.
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
- User id not found in registration token
- User is suspended - cannot register device
- Device not found
- Device OS and name are required
- Invalid device OS - ${deviceOs}
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/dcdeb9724d58721d.
Report an issue: GitHub.