{"record":{"id":"a762bc1f43ca834c","repo":"DIYgod/RSSHub","slug":"user-id-is-required-for-the-v2-home-timeline","errorCode":null,"errorMessage":"User ID is required for the v2 home timeline","messagePattern":"User ID is required for the v2 home timeline","errorType":"exception","errorClass":"InvalidParameterError","httpStatus":503,"severity":"warning","filePath":"lib/routes/twitter/api/developer-api/api.ts","lineNumber":326,"sourceCode":"            const response = await client.v2.get(`lists/${id}/tweets`, {\n                max_results: params?.count ?? 20,\n                expansions: 'author_id,attachments.media_keys,referenced_tweets.id,referenced_tweets.id.author_id',\n                'tweet.fields': 'created_at,entities,conversation_id,referenced_tweets,author_id,in_reply_to_user_id',\n                'user.fields': 'username,name,profile_image_url,description',\n                'media.fields': 'preview_image_url,url,type,width,height,variants',\n            });\n            return mapTweetResponseToLegacy(response);\n        },\n        config.cache.routeExpire,\n        false\n    );\n\nconst getHomeTimeline = (_id: string, params?: Record<string, any>) =>\n    cache.tryGet(\n        `twitter:home:${JSON.stringify(params)}`,\n        async () => {\n            if (!_id) {\n                throw new InvalidParameterError('User ID is required for the v2 home timeline');\n            }\n            const client = await getAppClient();\n            const response = await client.v2.get(`users/${_id}/timelines/reverse_chronological`, {\n                max_results: params?.count ?? 20,\n                expansions: 'author_id,attachments.media_keys,referenced_tweets.id,referenced_tweets.id.author_id',\n                'tweet.fields': 'created_at,entities,conversation_id,referenced_tweets,author_id,in_reply_to_user_id',\n                'user.fields': 'username,name,profile_image_url,description',\n                'media.fields': 'preview_image_url,url,type,width,height,variants',\n            });\n            return mapTweetResponseToLegacy(response);\n        },\n        config.cache.routeExpire,\n        false\n    );\n\nconst getHomeLatestTimeline = (id: string, params?: Record<string, any>) => getHomeTimeline(id, params);\n\nconst getUser = (id: string) => getUserData(id);","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/twitter/api/developer-api/api.ts#L308-L344","documentation":"InvalidParameterError from getHomeTimeline (v2 reverse-chronological): the function requires a user `_id` to call `users/{_id}/timelines/reverse_chronological`. An empty/falsy id cannot identify whose home timeline to fetch, so it throws inside the cache factory.","triggerScenarios":"getHomeTimeline is called with no/empty first argument — the `!_id` check on line 333 trips and throws. Home timeline requires user-context (OAuth1 user) auth, so the id must come from a configured user token.","commonSituations":"The route was invoked without resolving the current user id; `accessToken`/`accessSecret` were configured but the caller never fetched the token's user id; refactor dropped the id argument.","solutions":["Resolve the authenticated user's id (e.g. via `client.v2.me()`) and pass it as `_id`.","Ensure `TWITTER_ACCESS_TOKEN` and `TWITTER_ACCESS_SECRET` are set so a user-context client exists, then derive the id.","Guard the route to reject requests when no user-context client is configured."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!_id) throw new InvalidParameterError('User ID is required for the v2 home timeline');\nif (!config.twitter.accessToken || !config.twitter.accessSecret) throw new ConfigNotFoundError('Home timeline requires user-context OAuth credentials');","typeGuard":"const isUserId = (v: unknown): v is string => typeof v === 'string' && /^\\d+$/.test(v);","tryCatchPattern":null,"preventionTips":["Resolve the user id from the token via client.v2.me() before calling","Configure accessToken/accessSecret for user-context auth","Gate the home-timeline route on user-context config"],"tags":["twitter","invalid-parameter","home-timeline","oauth","developer-api"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}