{"record":{"id":"bfffec7ef6f35094","repo":"DIYgod/RSSHub","slug":"user-not-found-bfffec","errorCode":null,"errorMessage":"User not found","messagePattern":"User not found","errorType":"exception","errorClass":"InvalidParameterError","httpStatus":503,"severity":"warning","filePath":"lib/routes/twitter/api/mobile-api/api.ts","lineNumber":239,"sourceCode":"    if (id.startsWith('+')) {\n        return userByRestId(id.slice(1));\n    }\n    return userByScreenName(id);\n};\nconst getUserData = (id) => cache.tryGet(`twitter-userdata-${id}`, () => userByAuto(id));\nconst getUserID = async (id) => {\n    const userData = await getUserData(id);\n    return (userData.data?.user || userData.data?.user_result)?.result?.rest_id;\n};\nconst getUser = async (id) => {\n    const userData = await getUserData(id);\n    return (userData.data?.user || userData.data?.user_result)?.result?.legacy;\n};\n\nconst cacheTryGet = async (_id, params, func) => {\n    const id = await getUserID(_id);\n    if (id === undefined) {\n        throw new InvalidParameterError('User not found');\n    }\n    const funcName = func.name;\n    const paramsString = JSON.stringify(params);\n    return cache.tryGet(`twitter:${id}:${funcName}:${paramsString}`, () => func(id, params), config.cache.routeExpire, false);\n};\n\n// returns:\n// 1. nothing for some users\n// 2. HOT tweets for the other users, instead of the LATEST ones\nconst _getUserTweets = (id, params = {}) => cacheTryGet(id, params, getUserTweetsByID);\n// workaround for the above issue:\n// 1. getUserTweetsAndReplies return LATEST tweets and replies, which requires filtering\n//    a. if one replies a lot (e.g. elonmusk), there is sometimes no tweets left after filtering, caching may help\n// 2. getUserMedia return LATEST media tweets, which is a good plus\nconst getUserTweets = async (id, params = {}) => {\n    let tweets: any[] = [];\n    const rest_id = await getUserID(id);\n    await Promise.all(","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/twitter/api/mobile-api/api.ts#L221-L257","documentation":"InvalidParameterError from the Twitter mobile-API cacheTryGet helper: getUserID resolved no rest_id for the given id/username, so the account does not exist (or is suspended) from the mobile API's perspective. It throws before attempting the cached operation.","triggerScenarios":"A mobile-API function is called with a handle that yields no `userData.data.user.user_result.result.rest_id` — line 240 returns undefined, line 242-243 throws 'User not found'.","commonSituations":"Username typo, suspended/deleted account, or the mobile API endpoint is being challenged (logged-out) and returns no user payload; a stale negative cache could also be involved though this path recomputes.","solutions":["Verify the handle exists on x.com.","Confirm the mobile API auth cookies are still valid (an anonymous call returns degraded data).","Retry after rotating/re-authenticating the mobile session if responses are uniformly empty."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const id = await getUserID(_id);\nif (id === undefined) throw new InvalidParameterError(`Twitter user not found: ${_id}`);","typeGuard":"const isRestId = (v: unknown): v is string => typeof v === 'string' && /^\\d+$/.test(v);","tryCatchPattern":"try { return await cacheTryGet(_id, params, func); }\ncatch (e) { if (e instanceof InvalidParameterError && /User not found/.test(e.message)) { /* re-auth mobile session if responses are uniformly empty */ } throw e; }","preventionTips":["Keep mobile-API session cookies fresh","Validate handle format before lookup","Distinguish suspended vs unknown in error mapping"],"tags":["twitter","invalid-parameter","user-not-found","mobile-api","authentication"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}