{"record":{"id":"ba3d63cad6ebf2d7","repo":"DIYgod/RSSHub","slug":"invalid-time-range-finalsearchparams-time-range","errorCode":null,"errorMessage":"Invalid time range: ${finalSearchParams.time_range}","messagePattern":"Invalid time range: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/voronoiapp/common.ts","lineNumber":30,"sourceCode":"    tab?: string;\n    time_range?: string;\n    category?: string;\n    order?: string;\n    author?: string;\n    limit?: number;\n    offset?: number;\n}): Promise<DataItem[]> {\n    const baseUrl = 'https://9oyi4rk426.execute-api.ca-central-1.amazonaws.com/production/post';\n    const url = new URL(baseUrl);\n    const finalSearchParams = {\n        limit: 20,\n        offset: 0,\n        ...params,\n    };\n    if (finalSearchParams.time_range !== undefined) {\n        finalSearchParams.time_range = finalSearchParams.time_range.toUpperCase();\n        if (TimeRangeParam.options.every((option) => option.value !== finalSearchParams.time_range)) {\n            throw new Error(`Invalid time range: ${finalSearchParams.time_range}`);\n        }\n        // The Voronoi API doesn't support \"ALL\"\n        if (finalSearchParams.time_range === 'ALL') {\n            finalSearchParams.time_range = undefined;\n        }\n    }\n    if (finalSearchParams.category !== undefined && finalSearchParams.category !== null) {\n        const category = finalSearchParams.category;\n        finalSearchParams.category = CategoryParam.options.find((option) => option.value.toLowerCase() === category.toLowerCase())?.value;\n        if (finalSearchParams.category === undefined) {\n            throw new Error(`Invalid category: ${finalSearchParams.category}`);\n        }\n    }\n    if (finalSearchParams.tab !== undefined && finalSearchParams.tab !== null) {\n        finalSearchParams.tab = finalSearchParams.tab.toUpperCase();\n        if (!Object.values(TabMap).includes(finalSearchParams.tab)) {\n            throw new Error(`Invalid tab: ${finalSearchParams.tab}`);\n        }","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/voronoiapp/common.ts#L12-L48","documentation":"Thrown by the Voronoi `getPostItems` helper when the `time_range` parameter, after uppercasing, is not one of the values in `TimeRangeParam.options` (`WEEK`, `MONTH`, `YEAR`, `ALL`). The validation runs `.every()` to check that no option matches — if none match, it throws. This is a generic `Error`.","triggerScenarios":"Calling `getPostItems({ time_range: 'DAY' })` or passing any string not equal (after `.toUpperCase()`) to `WEEK`, `MONTH`, `YEAR`, or `ALL`. In the popular route, this is triggered by the third path segment: `/voronoiapp/popular/:tab/:time_range/:category`.","commonSituations":"User passes a custom time range like `DAY`, `HOUR`, or `TODAY` that the API doesn't support. Or passes a numeric value. The `ALL` value is special-cased: it's valid for validation but then set to `undefined` before the API call because the Voronoi API doesn't support it.","solutions":["Use one of the valid time range values: `WEEK`, `MONTH`, `YEAR`, or `ALL` (case-insensitive).","Omit the time_range parameter to use the default `MONTH` in the popular route.","If calling `getPostItems` directly, pass `undefined` instead of an invalid string."],"exampleFix":"// before\nGET /voronoiapp/popular/most-popular/DAY\n// after\nGET /voronoiapp/popular/most-popular/WEEK","handlingStrategy":"validation","validationCode":"const VALID_TIME_RANGES = ['WEEK', 'MONTH', 'YEAR', 'ALL'];\nfunction isValidTimeRange(tr: string): boolean {\n    return VALID_TIME_RANGES.includes(tr.toUpperCase());\n}\n// Validate before calling getPostItems\nif (time_range && !isValidTimeRange(time_range)) {\n    throw new InvalidParameterError(`Invalid time range: ${time_range}. Valid: ${VALID_TIME_RANGES.join(', ')}`);\n}","typeGuard":"function isValidTimeRange(tr: string): tr is 'WEEK' | 'MONTH' | 'YEAR' | 'ALL' {\n    return ['WEEK', 'MONTH', 'YEAR', 'ALL'].includes(tr.toUpperCase());\n}","tryCatchPattern":null,"preventionTips":["Use the route's documented TimeRangeParam options rather than guessing.","Validate at the route boundary (in the handler) before calling getPostItems, not just inside the helper."],"tags":["parameter-validation","voronoiapp","rss-route","enum-validation"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}