DIYgod/RSSHub · error · InvalidParameterError
Invalid keyword
Error message
Invalid keyword
What it means
An InvalidParameterError thrown when the oceanengine index route is invoked without a keyword. InvalidParameterError signals a caller-side mistake (bad URL/route input) rather than an upstream or config problem. The keyword is the core subject of the trend query, so an empty value is rejected before any Playwright/network work begins.
Source
Thrown at lib/routes/oceanengine/arithmetic-index.tsx:110
keyword: '热点关键词',
},
description: '爬取巨量算数近 6 个月的抖音指数,解密后提取指数波峰当日的热门搜索关键词,生成为 RSS。可用于追踪新闻热点事件。',
features: {
requirePuppeteer: true,
antiCrawler: true,
},
name: '抖音指数波峰',
maintainers: ['Jkker'],
handler,
};
export async function handler(ctx) {
const now = dayjs();
const start_date = now.subtract(DEFAULT_FETCH_DURATION_MONTH, 'month').format('YYYYMMDD');
const end_date = now.format('YYYYMMDD');
const keyword = ctx.req.param('keyword');
if (!keyword) {
throw new InvalidParameterError('Invalid keyword');
}
const isToutiao = routePath(ctx) === '/oceanengine/index/:keyword/toutiao';
const channel = isToutiao ? 'toutiao' : 'aweme';
const channelName = isToutiao ? '头条' : '抖音';
const link = `https://trendinsight.oceanengine.com/arithmetic-index/analysis?keyword=${keyword}&appName=${channel}`;
const item = await cache.tryGet(
link,
async () => {
const context = await playwright();
const page = await context.newPage();
await page.route('**/*', (route) => {
const request = route.request();
request.resourceType() === 'document' || request.resourceType() === 'script' || request.resourceType() === 'xhr' ? route.continue() : route.abort();
});
await page.goto('https://trendinsight.oceanengine.com/arithmetic-index');View on GitHub (pinned to bed535e087)
Solutions
- Provide a non-empty keyword in the route URL, e.g. /oceanengine/index/<keyword>.
- If the keyword legitimately contains special characters, URL-encode it so the router binds a non-empty value.
- Verify the request path actually reaches this handler with the segment intact (check any upstream proxy/rewrite).
Example fix
// before
const keyword = ctx.req.param('keyword');
if (!keyword) {
throw new InvalidParameterError('Invalid keyword');
}
// after — include the offending value in the message for easier diagnosis
if (!keyword || !keyword.trim()) {
throw new InvalidParameterError(`Invalid keyword: received ${JSON.stringify(keyword)}`);
} Defensive patterns
Strategy: validation
Validate before calling
// Validate keyword at the route boundary before delegating to the handler.
const keyword = ctx.req.param('keyword');
if (typeof keyword !== 'string' || keyword.trim() === '') {
return ctx.json({ error: 'A non-empty keyword is required' }, 400);
} Type guard
const isNonEmptyKeyword = (k: unknown): k is string => typeof k === 'string' && k.trim().length > 0;
Prevention
- Mark :keyword as required in the route definition so the framework rejects empty segments.
- Document example keywords in the route description to guide subscribers.
- URL-encode keywords with special characters when constructing feed URLs.
When it happens
Trigger: The path is /oceanengine/index/:keyword but the :keyword segment is empty or missing (e.g. a malformed request to /oceanengine/index/ with a trailing slash, or route binding yields an empty string), so ctx.req.param('keyword') is falsy.
Common situations: A subscriber copied a route URL but left the keyword blank; an RSS client URL-encoded the keyword into nothing; the route was mounted under a different prefix that swallowed the segment. Note the route definition path '/index/:keyword' makes an empty keyword hard to produce via normal routing, so this is mostly a defensive guard.
Related errors
- Invalid type: ${type}
- Invalid type parameter
- unknown site: ${site}
- Invalid type parameter
- Invalid category: ${category}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/299de86f7ec52355.
Report an issue: GitHub.