Mintplex-Labs/anything-llm · error
User id not found in registration token
Error message
User id not found in registration token
What it means
In multi-user mode (SystemSettings.isMultiUserMode()), validRegistrationToken requires the temp token to carry a userId. registerTempToken embeds the id of the user who generated connect-info (or null in single-user mode); if userId is absent the middleware responds 400 { error: 'User id not found in registration token' }.
Source
Thrown at server/endpoints/mobile/middleware/index.js:74
if (!tempToken)
return response
.status(400)
.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",
});
}
}View on GitHub (pinned to 3aec848f28)
Solutions
- Generate a fresh connect-info while logged in as the intended user on the now-multi-user instance and rescan
- Make sure connect-info is requested after the multi-user mode switch completes
- Use only the ?t= token from the newest connect-info response
Defensive patterns
Strategy: retry
Try / catch
try {
await register(tempToken);
} catch (e) {
if (e.status === 400 && e.body?.error === 'User id not found in registration token') {
const fresh = await fetchConnectInfoAs(currentUser); // token from multi-user session
return register(fresh);
}
throw e;
} Prevention
- Regenerate connect-info after toggling multi-user mode — old URLs are mode-stamped
- Discard cached pairing URLs across configuration changes
- Generate connect-info from an authenticated session in multi-user deployments
When it happens
Trigger: connect-info was generated while the instance ran in single-user mode (tokenData.userId = null) and multi-user mode was enabled before /mobile/register ran; or an anonymous connect-info URL is used against a multi-user instance.
Common situations: Mode flipped between generating the QR and scanning it; the app caches an old pairing URL produced before multi-user was enabled.
Related errors
- User not found
- User is suspended - cannot register device
- Device OS and name are required
- Invalid device OS - ${deviceOs}
- User is suspended.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/77b9397585f936a1.
Report an issue: GitHub.