{"record":{"id":"cc6bb5da3a2b9fe3","repo":"DIYgod/RSSHub","slug":"discuz","errorCode":null,"errorMessage":"不支持当前Discuz版本.","messagePattern":"不支持当前Discuz版本\\.","errorType":"exception","errorClass":"InvalidParameterError","httpStatus":null,"severity":"error","filePath":"lib/routes/discuz/discuz.ts","lineNumber":184,"sourceCode":"                    title: a.text(),\n                    link: fixUrl(a.attr('href'), link),\n                    pubDate: $item.find('td.by:nth-child(3) em span').last().length ? parseDate($item.find('td.by:nth-child(3) em span').last().text().trim()) : undefined,\n                    author: $item.find('td.by:nth-child(3) cite a').text().trim(),\n                };\n            });\n\n        items = await Promise.all(\n            list.map((item) =>\n                cache.tryGet(item.link!, async () => {\n                    const { description } = await loadContent(item.link, charset, header);\n\n                    item.description = description;\n                    return item;\n                })\n            )\n        );\n    } else {\n        throw new InvalidParameterError('不支持当前Discuz版本.');\n    }\n\n    return {\n        title: $('head > title').text(),\n        description: $('head > meta[name=description]').attr('content'),\n        link,\n        item: items,\n    };\n}\n","sourceCodeStart":166,"sourceCodeEnd":194,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/discuz/discuz.ts#L166-L194","documentation":"Thrown by the Discuz generic forum route when the detected Discuz version string does not match either 'DISCUZ! 7' (7.x series) or 'DISCUZ! X' (X series). The version is obtained from the route's optional `ver` path parameter (e.g. `/discuz/x/`) or, if absent, from the page's `<meta name=\"generator\">` tag. The route only supports these two families; any other version string (e.g. Discuz! 6.x, Discuz! 3.x without 'X' prefix, or a modified forum that strips the generator tag in a non-standard way) hits this else-branch.","triggerScenarios":"Supplying a forum URL whose generator meta tag reads something other than 'DISCUZ! 7*' or 'DISCUZ! X*'; supplying an explicit `ver` param that does not start with '7' or 'X' (the regex `[7x]` only matches a single '7' or 'x'); the forum being behind a CDN/anti-bot layer that replaces the HTML and removes the generator meta tag.","commonSituations":"The target forum upgraded to a Discuz version not yet supported by this route; the forum uses a heavily customized theme that omits or renames the generator meta tag; the forum returns an interstitial anti-bot page (e.g. a JS challenge) instead of the real HTML, so the generator meta tag is absent or reads differently.","solutions":["Visit the forum URL in a browser, inspect the page source for <meta name=\"generator\">, and confirm whether it reads 'DISCUZ! X*' or 'DISCUZ! 7*'.","If the meta tag is missing or non-standard, supply the version explicitly in the route path: use /discuz/x/<url-encoded-link> for X series or /discuz/7/<url-encoded-link> for 7.x series.","If the forum is behind an anti-bot wall, wait and retry, or try from a different IP. The route already retries with cookies but may still fail on JS challenges.","If the forum runs a genuinely unsupported Discuz version, open an issue or PR to add support for that version's HTML structure."],"exampleFix":"// before\nconst version = ver ? `DISCUZ! ${ver}` : $('head > meta[name=generator]').attr('content');\nif (version.toUpperCase().startsWith('DISCUZ! 7')) { ... }\nelse if (version.toUpperCase().startsWith('DISCUZ! X')) { ... }\nelse { throw new InvalidParameterError('不支持当前Discuz版本.'); }\n\n// after — case-insensitive 'X' anywhere in version string, or use detected version as fallback\nif (version?.toUpperCase().includes('DISCUZ! 7') || ver === '7') { ... }\nelse if (version?.toUpperCase().includes('DISCUZ! X') || /^(x)$/i.test(ver)) { ... }\nelse { throw new InvalidParameterError(`不支持当前Discuz版本: ${version ?? 'unknown'}. Supported: 7.x, X series.`); }","handlingStrategy":"validation","validationCode":"// Before calling the route, verify the forum's Discuz version\n// Check the generator meta tag\nconst resp = await fetch(forumUrl);\nconst html = await resp.text();\nconst match = html.match(/<meta\\s+name=[\"']generator[\"']\\s+content=[\"']([^\"']+)[\"']/i);\nconst version = match?.[1];\nconst isSupported = version?.toUpperCase().startsWith('DISCUZ! 7') || version?.toUpperCase().startsWith('DISCUZ! X');\nif (!isSupported) {\n    console.warn(`Forum version ${version} may not be supported. Use /discuz/x/ or /discuz/7/ prefix.`);\n}","typeGuard":null,"tryCatchPattern":"// Wrap the route call and catch InvalidParameterError specifically\ntry {\n    const feed = await fetch(`${rsshubUrl}/discuz/${ver}/${encodeURIComponent(forumUrl)}`);\n} catch (e) {\n    if (e.message.includes('不支持当前Discuz版本')) {\n        // Try the other version prefix\n        const altVer = ver === 'x' ? '7' : 'x';\n        return fetch(`${rsshubUrl}/discuz/${altVer}/${encodeURIComponent(forumUrl)}`);\n    }\n    throw e;\n}","preventionTips":["Always specify the version prefix in the route path (/discuz/x/ or /discuz/7/) rather than relying on auto-detection.","Before subscribing, verify the forum's generator meta tag in a browser.","If the forum uses anti-bot measures, test with the explicit version prefix first."],"tags":["discuz","version-detection","invalid-parameter","web-scraping"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}