{"record":{"id":"724cd5cb45abd75f","repo":"DIYgod/RSSHub","slug":"invalid-date-format-expected-yyyymmdd-for-exampl","errorCode":null,"errorMessage":"Invalid date format. Expected YYYYMMDD, for example `20260316`. ","messagePattern":"Invalid date format\\. Expected YYYYMMDD, for example `20260316`\\. ","errorType":"exception","errorClass":"Error","httpStatus":503,"severity":"warning","filePath":"lib/routes/fjdaily/index.ts","lineNumber":92,"sourceCode":"const getItemDescription = (detail: CheerioAPI) => {\n    const mainContent = detail('#content');\n    const attachment = detail('.attachment');\n    const mainDescription = getDescription(mainContent);\n    const mainMediaSources = new Set(\n        mainContent\n            .find('img, video, audio, source')\n            .toArray()\n            .map((item: Element) => getNodeSrc(item))\n            .filter(Boolean)\n    );\n\n    return mergeDescription(detail, mainDescription, attachment, mainMediaSources);\n};\n\nconst getIssueDate = async (date: string | undefined) => {\n    if (date) {\n        if (!/^\\d{8}$/.test(date)) {\n            throw new Error('Invalid date format. Expected YYYYMMDD, for example `20260316`. ');\n        }\n\n        return {\n            yearMonth: date.slice(0, 6),\n            day: date.slice(6, 8),\n        };\n    }\n\n    const indexResponse = await got(`${ROOT_URL}/pc/col/index.html`);\n    const $ = load(indexResponse.data);\n    const latestPath = $('#list li:first-child a').attr('href');\n\n    if (!latestPath) {\n        throw new Error('Failed to locate the latest Fujian Daily edition.');\n    }\n\n    const [, yearMonth, day] = latestPath.match(/(\\d{6})\\/(\\d{2})\\/node_\\d+\\.html/) ?? [];\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/fjdaily/index.ts#L74-L110","documentation":"Thrown by the Fjdaily (Fujian Daily) route's `getIssueDate` function when the user-supplied `date` parameter does not match the regex `/^\\d{8}$/`. The route expects exactly 8 digits in YYYYMMDD format (e.g., `20260316`). This is pre-flight validation before any network request is made.","triggerScenarios":"A user passes a date in the wrong format: `/fjdaily/2026-03-16` (dashes), `/fjdaily/2026/03/16` (slashes), `/fjdaily/260316` (6 digits), `/fjdaily/202603160` (9 digits), or any non-numeric string. The regex test fails immediately.","commonSituations":"User passes a date with separators (dashes, slashes, dots). User passes a 6-digit or 10-digit date. User passes a locale-formatted date string. User passes a date that is valid as a date but wrong as a format (e.g., `March 16, 2026`).","solutions":["Format the date as exactly 8 digits: YYYYMMDD, e.g., `/fjdaily/20260316`.","Remove all separators (dashes, slashes) from the date string.","Omit the date parameter entirely to fetch the latest edition automatically."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function validateDateString(date: string | undefined): { yearMonth: string; day: string } {\n    if (!date) throw new Error('Date is required');\n    if (!/^\\d{8}$/.test(date)) {\n        throw new Error('Invalid date format. Expected YYYYMMDD, e.g., 20260316');\n    }\n    return { yearMonth: date.slice(0, 6), day: date.slice(6, 8) };\n}","typeGuard":"function isValidYYYYMMDD(date: string): boolean {\n    if (!/^\\d{8}$/.test(date)) return false;\n    const year = parseInt(date.slice(0, 4));\n    const month = parseInt(date.slice(4, 6));\n    const day = parseInt(date.slice(6, 8));\n    return year >= 1900 && month >= 1 && month <= 12 && day >= 1 && day <= 31;\n}","tryCatchPattern":null,"preventionTips":["Format dates as exactly 8 digits: YYYYMMDD (no separators).","Omit the date parameter to auto-fetch the latest edition.","Validate both format and logical date ranges (month 1-12, day 1-31)."],"tags":["parameter-validation","date-format","regex-check","fjdaily"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}