{"record":{"id":"299de86f7ec52355","repo":"DIYgod/RSSHub","slug":"invalid-keyword","errorCode":null,"errorMessage":"Invalid keyword","messagePattern":"Invalid keyword","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"error","filePath":"lib/routes/oceanengine/arithmetic-index.tsx","lineNumber":110,"sourceCode":"        keyword: '热点关键词',\n    },\n    description: '爬取巨量算数近 6 个月的抖音指数，解密后提取指数波峰当日的热门搜索关键词，生成为 RSS。可用于追踪新闻热点事件。',\n    features: {\n        requirePuppeteer: true,\n        antiCrawler: true,\n    },\n    name: '抖音指数波峰',\n    maintainers: ['Jkker'],\n    handler,\n};\n\nexport async function handler(ctx) {\n    const now = dayjs();\n    const start_date = now.subtract(DEFAULT_FETCH_DURATION_MONTH, 'month').format('YYYYMMDD');\n    const end_date = now.format('YYYYMMDD');\n    const keyword = ctx.req.param('keyword');\n    if (!keyword) {\n        throw new InvalidParameterError('Invalid keyword');\n    }\n    const isToutiao = routePath(ctx) === '/oceanengine/index/:keyword/toutiao';\n\n    const channel = isToutiao ? 'toutiao' : 'aweme';\n    const channelName = isToutiao ? '头条' : '抖音';\n\n    const link = `https://trendinsight.oceanengine.com/arithmetic-index/analysis?keyword=${keyword}&appName=${channel}`;\n\n    const item = await cache.tryGet(\n        link,\n        async () => {\n            const context = await playwright();\n            const page = await context.newPage();\n            await page.route('**/*', (route) => {\n                const request = route.request();\n                request.resourceType() === 'document' || request.resourceType() === 'script' || request.resourceType() === 'xhr' ? route.continue() : route.abort();\n            });\n            await page.goto('https://trendinsight.oceanengine.com/arithmetic-index');","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/oceanengine/arithmetic-index.tsx#L92-L128","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\nconst keyword = ctx.req.param('keyword');\nif (!keyword) {\n    throw new InvalidParameterError('Invalid keyword');\n}\n\n// after — include the offending value in the message for easier diagnosis\nif (!keyword || !keyword.trim()) {\n    throw new InvalidParameterError(`Invalid keyword: received ${JSON.stringify(keyword)}`);\n}","handlingStrategy":"validation","validationCode":"// Validate keyword at the route boundary before delegating to the handler.\nconst keyword = ctx.req.param('keyword');\nif (typeof keyword !== 'string' || keyword.trim() === '') {\n    return ctx.json({ error: 'A non-empty keyword is required' }, 400);\n}","typeGuard":"const isNonEmptyKeyword = (k: unknown): k is string => typeof k === 'string' && k.trim().length > 0;","tryCatchPattern":null,"preventionTips":["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."],"tags":["validation","invalid-parameter","user-input","route-param"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}