DIYgod/RSSHub · warning · InvalidParameterError
User ID is required for the v2 home timeline
Error message
User ID is required for the v2 home timeline
What it means
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.
Source
Thrown at lib/routes/twitter/api/developer-api/api.ts:326
const response = await client.v2.get(`lists/${id}/tweets`, {
max_results: params?.count ?? 20,
expansions: 'author_id,attachments.media_keys,referenced_tweets.id,referenced_tweets.id.author_id',
'tweet.fields': 'created_at,entities,conversation_id,referenced_tweets,author_id,in_reply_to_user_id',
'user.fields': 'username,name,profile_image_url,description',
'media.fields': 'preview_image_url,url,type,width,height,variants',
});
return mapTweetResponseToLegacy(response);
},
config.cache.routeExpire,
false
);
const getHomeTimeline = (_id: string, params?: Record<string, any>) =>
cache.tryGet(
`twitter:home:${JSON.stringify(params)}`,
async () => {
if (!_id) {
throw new InvalidParameterError('User ID is required for the v2 home timeline');
}
const client = await getAppClient();
const response = await client.v2.get(`users/${_id}/timelines/reverse_chronological`, {
max_results: params?.count ?? 20,
expansions: 'author_id,attachments.media_keys,referenced_tweets.id,referenced_tweets.id.author_id',
'tweet.fields': 'created_at,entities,conversation_id,referenced_tweets,author_id,in_reply_to_user_id',
'user.fields': 'username,name,profile_image_url,description',
'media.fields': 'preview_image_url,url,type,width,height,variants',
});
return mapTweetResponseToLegacy(response);
},
config.cache.routeExpire,
false
);
const getHomeLatestTimeline = (id: string, params?: Record<string, any>) => getHomeTimeline(id, params);
const getUser = (id: string) => getUserData(id);View on GitHub (pinned to bed535e087)
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.
Defensive patterns
Strategy: validation
Validate before calling
if (!_id) throw new InvalidParameterError('User ID is required for the v2 home timeline');
if (!config.twitter.accessToken || !config.twitter.accessSecret) throw new ConfigNotFoundError('Home timeline requires user-context OAuth credentials'); Type guard
const isUserId = (v: unknown): v is string => typeof v === 'string' && /^\d+$/.test(v);
Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/a762bc1f43ca834c.
Report an issue: GitHub.