{"record":{"id":"e1d1bfdd653441f5","repo":"DIYgod/RSSHub","slug":"invalid-site-e1d1bf","errorCode":null,"errorMessage":"Invalid site","messagePattern":"Invalid site","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"warning","filePath":"lib/routes/hedwig/posts.ts","lineNumber":32,"sourceCode":"});\n\nexport const route: Route = {\n    path: '/posts/:site',\n    categories: ['blog'],\n    example: '/hedwig/posts/walnut',\n    parameters: { site: '站点名，原则上只要是 `{site}.hedwig.pub` 都可以匹配' },\n    features: {\n        supportRadar: false,\n    },\n    name: 'Posts',\n    url: 'hedwig.pub',\n    maintainers: ['zwithz', 'GetToSet'],\n    view: ViewType.Articles,\n    handler: async (ctx) => {\n        const { site } = ctx.req.param();\n\n        if (!isValidHost(site)) {\n            throw new InvalidParameterError('Invalid site');\n        }\n\n        const baseUrl = `https://${site}.hedwig.pub`;\n\n        const response = await ofetch(baseUrl);\n        const $ = load(response);\n\n        const text = $('script#__NEXT_DATA__').text();\n        const json = JSON.parse(text);\n\n        const pageProps = json.props.pageProps;\n\n        const list = pageProps.issuesByNewsletter.map((item) => {\n            const description = item.blocks.map((block) => md.render(block.markdown.text)).join('');\n            return {\n                title: item.subject,\n                description,\n                pubDate: timezone(parseDate(item.publishAt, 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'), 0),","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/hedwig/posts.ts#L14-L50","documentation":"Thrown by the Hedwig newsletter posts route when `isValidHost(site)` returns false for the `:site` path parameter. The route constructs `https://${site}.hedwig.pub` and fetches it, so the `site` value must be a syntactically valid hostname label. The `isValidHost` utility performs a DNS resolution check to confirm the subdomain actually exists before attempting the HTTP fetch.","triggerScenarios":"Requesting `/hedwig/posts/<site>` where `<site>` is not a valid DNS label or where `<site>.hedwig.pub` does not resolve in DNS. Examples: special characters, spaces, extremely long labels, or a newsletter subdomain that was deleted.","commonSituations":"Typo in the newsletter name, using a newsletter that was unpublished/removed, or injecting URL-unsafe characters. The route description says 'any `{site}.hedwig.pub` should match' but DNS validation enforces it.","solutions":["Confirm the newsletter exists by visiting `https://<site>.hedwig.pub` in a browser.","Check the spelling of the `:site` parameter — it must match the subdomain exactly.","If the newsletter was removed, there is no fix other than choosing a different one."],"exampleFix":"// before (broken)\n// GET /hedwig/posts/nonexistent-newsletter\n\n// after (correct)\n// GET /hedwig/posts/walnut","handlingStrategy":"validation","validationCode":"// The route already uses isValidHost(site) before the fetch.\n// Callers can pre-check:\nimport { isValidHost } from '@/utils/valid-host';\nif (!isValidHost(site)) {\n    throw new InvalidParameterError('Invalid site');\n}","typeGuard":"async function isValidHedwigSite(site: string): Promise<boolean> {\n    // isValidHost already does DNS resolution\n    const { isValidHost } = await import('@/utils/valid-host');\n    return isValidHost(site);\n}","tryCatchPattern":null,"preventionTips":["Use only documented newsletter site names.","Verify the subdomain exists at `https://<site>.hedwig.pub` before subscribing.","Handle `InvalidParameterError` on the client side to show a user-friendly message."],"tags":["parameter-validation","dns","rsshub","blog"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}