{"record":{"id":"e900aebd94a1a96d","repo":"DIYgod/RSSHub","slug":"unknown-host-url-host","errorCode":null,"errorMessage":"Unknown host: ${url.host}","messagePattern":"Unknown host: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"lib/routes/gov/maonan/maonan.ts","lineNumber":154,"sourceCode":"                            case '/zcjdpt':\n                                return {\n                                    title: content('meta[name=\"ArticleTitle\"]').attr('content')!,\n                                    description: content('.wrap').html(),\n                                    pubDate,\n                                    link,\n                                    author: content('meta[name=\"ContentSource\"]').attr('content') === '本网' ? '茂名市茂南区人民政府网' : content('meta[name=\"ContentSource\"]').attr('content'),\n                                };\n                            default:\n                                return {\n                                    title: content('.newsContainer_title').text(),\n                                    description: content('.newsContainer_text').html(),\n                                    pubDate,\n                                    link,\n                                    author: content('.author').text().trim() === '本网' ? '茂名市茂南区人民政府网' : content('.author').text().trim(),\n                                };\n                        }\n                    default:\n                        throw new Error(`Unknown host: ${url.host}`);\n                }\n            });\n        })\n    );\n\n    return {\n        title: `茂名市茂南区人民政府 - ${name}`,\n        link: `${host}/${id}`,\n        item: items,\n    };\n}\n","sourceCodeStart":136,"sourceCodeEnd":166,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/gov/maonan/maonan.ts#L136-L166","documentation":"Thrown by the Maonan district government route inside a cache.tryGet callback when processing individual article links. After extracting article URLs from the list page, each link's URL host is checked in a switch statement. Only 'mp.weixin.qq.com' and 'www.maonan.gov.cn' have handlers. Any other host triggers this error.","triggerScenarios":"The article list page (www.maonan.gov.cn/{id}/) contains links whose host is neither mp.weixin.qq.com (WeChat articles) nor www.maonan.gov.cn (government site articles). This could be an external redirect, a CDN link, or a new subdomain. The error is thrown inside a Promise.all map, so it will reject the entire feed generation.","commonSituations":"The Maonan government site added links to a new domain or subdomain (e.g., a new content management system); external partner links appear in the article list; the list CSS selector matches unintended links (e.g., navigation links to other gov.cn subdomains).","solutions":["Inspect the article list page to identify what new hosts are appearing in links","Add a new case to the switch statement in the cache.tryGet callback for the new host","If the links are non-article navigation, tighten the list CSS selector to exclude them","Consider making the error non-fatal by returning a partial item instead of throwing, to avoid breaking the entire feed"],"exampleFix":"// before\ndefault:\n    throw new Error(`Unknown host: ${url.host}`);\n\n// after (graceful degradation — skip unknown hosts instead of failing the entire feed)\ndefault:\n    return {\n        title: $item.text(),\n        description: `Content from ${url.host} is not supported`,\n        pubDate,\n        link,\n        author: url.host,\n    };","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const SUPPORTED_HOSTS = new Set(['mp.weixin.qq.com', 'www.maonan.gov.cn']);\nfunction isSupportedHost(url: URL): boolean {\n    return SUPPORTED_HOSTS.has(url.host);\n}","tryCatchPattern":"// Inside the Promise.all map, catch per-item errors instead of failing the feed:\nconst items = await Promise.all(\n    list.map(async (i, item) => {\n        try {\n            // ... existing logic\n        } catch (e) {\n            if (e.message.includes('Unknown host')) {\n                return null; // skip unsupported hosts gracefully\n            }\n            throw e;\n        }\n    })\n);\nconst validItems = items.filter(Boolean);","preventionTips":["Filter the list selector to only include links to known hosts before processing","Use a Set of supported hosts for O(1) lookup","Return partial results (skip unsupported links) instead of failing the entire feed","Monitor for new hosts appearing in the article list"],"tags":["scraper","url-parsing","brittle","graceful-degradation","government"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}