{"record":{"id":"dcdeb9724d58721d","repo":"Mintplex-Labs/anything-llm","slug":"user-not-found-dcdeb9","errorCode":null,"errorMessage":"User not found","messagePattern":"User not found","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/endpoints/mobile/middleware/index.js","lineNumber":77,"sourceCode":"        .json({ error: \"Registration token is required\" });\n\n    const tempTokenData = MobileDevice.tempToken(tempToken);\n    if (!tempTokenData)\n      return response\n        .status(400)\n        .json({ error: \"Invalid or expired registration token\" });\n\n    // If in multi-user mode, we need to validate the user id\n    // associated exists, is not banned and then associate with locals so we can reuse it later.\n    // If not in multi-user mode then simply having a valid token is enough.\n    const multiUserMode = await SystemSettings.isMultiUserMode();\n    if (multiUserMode) {\n      if (!tempTokenData.userId)\n        return response\n          .status(400)\n          .json({ error: \"User id not found in registration token\" });\n      const user = await User.get({ id: Number(tempTokenData.userId) });\n      if (!user) return response.status(400).json({ error: \"User not found\" });\n      if (user.suspended)\n        return response\n          .status(400)\n          .json({ error: \"User is suspended - cannot register device\" });\n      response.locals.user = user;\n    }\n\n    next();\n  } catch (error) {\n    console.error(\"validRegistrationToken:error\", error);\n    response.status(500).json({\n      error: \"Invalid middleware response from validRegistrationToken\",\n    });\n  }\n}\n\nmodule.exports = {\n  validDeviceToken,","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/mobile/middleware/index.js#L59-L95","documentation":"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.","triggerScenarios":"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.","commonSituations":"Admin offboarded/deleted a user mid pairing; long-lived pairing URLs shared then used after cleanup.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await register(tempToken);\n} catch (e) {\n  if (e.status === 400 && e.body?.error === 'User not found') {\n    const fresh = await fetchConnectInfoAs(activeUser); // owner was deleted\n    return register(fresh);\n  }\n  throw e;\n}","preventionTips":["Invalidate outstanding pairing URLs when deleting users","Generate connect-info from an account verified to still exist","Pair promptly after generating codes"],"tags":["mobile","registration","multi-user","user-deleted","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-23T16:17:53.355Z"}