{"record":{"id":"bb3ff1d64d4cf409","repo":"DIYgod/RSSHub","slug":"invalid-type-bb3ff1","errorCode":null,"errorMessage":"Invalid type","messagePattern":"Invalid type","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":503,"severity":"error","filePath":"lib/routes/solidot/main.ts","lineNumber":61,"sourceCode":"        },\n    },\n    features: {\n        requireConfig: false,\n        requirePuppeteer: false,\n        antiCrawler: false,\n        supportBT: false,\n        supportPodcast: false,\n        supportScihub: false,\n    },\n    name: '最新消息',\n    maintainers: ['sgqy', 'hang333', 'TonyRL'],\n    handler,\n};\n\nasync function handler(ctx) {\n    const type = ctx.req.param('type') ?? 'www';\n    if (!isValidHost(type)) {\n        throw new InvalidParameterError('Invalid type');\n    }\n\n    const base_url = `https://${type}.solidot.org`;\n    const response = await got({\n        method: 'get',\n        url: base_url,\n    });\n    const data = response.data; // content is html format\n    const $ = load(data);\n\n    // get urls\n    const a = $('div.block_m').find('div.bg_htit > h2 > a');\n    const urls = Array.from(a, (element) => $(element).attr('href'));\n\n    // get articles\n    const msg_list = await Promise.all(urls.map((u) => cache.tryGet(u!, () => get_article(u))));\n\n    // feed the data","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/solidot/main.ts#L43-L79","documentation":"Thrown as an InvalidParameterError when the optional `type` path parameter on the Solidot route fails the isValidHost() check. The type parameter is used as a subdomain: https://<type>.solidot.org. isValidHost validates it against a DNS-label regex to prevent malformed or malicious hostnames. The route provides 17 documented type options (www, startup, linux, science, technology, mobile, apple, hardware, software, security, games, books, ask, idle, blog, cloud, story) but technically any valid DNS label passes.","triggerScenarios":"A GET to /solidot/<type> where type contains characters invalid for DNS labels (underscores, dots, special chars), or is a type that passes the regex but does not resolve to a real Solidot subdomain (e.g. /solidot/foo). The regex only checks syntax, not existence.","commonSituations":"User types a section name that doesn't match the documented options; URL encoding produces unexpected characters; or a scanner probes with arbitrary paths.","solutions":["Use one of the 17 documented types (www, startup, linux, science, technology, mobile, apple, hardware, software, security, games, books, ask, idle, blog, cloud, story) or omit the type for the default 'www'.","Ensure the type contains only alphanumeric characters and hyphens with no leading/trailing hyphens.","If no specific section is needed, request /solidot with no path parameter to get the main feed."],"exampleFix":"// before\nGET /solidot/tech_news\n\n// after\nGET /solidot/technology","handlingStrategy":"validation","validationCode":"const VALID_TYPES = ['www', 'startup', 'linux', 'science', 'technology', 'mobile', 'apple', 'hardware', 'software', 'security', 'games', 'books', 'ask', 'idle', 'blog', 'cloud', 'story'];\nconst type = ctx.req.param('type') ?? 'www';\nif (!VALID_TYPES.includes(type)) {\n    throw new InvalidParameterError(`Invalid type. Valid types: ${VALID_TYPES.join(', ')}`);\n}","typeGuard":"function isValidSolidotType(t: string | undefined): boolean {\n    if (!t) return true;\n    return isValidHost(t);\n}","tryCatchPattern":null,"preventionTips":["Consider using an explicit allowlist of valid Solidot subdomains instead of the generic isValidHost regex.","Include valid type values in the error message body for user self-service.","Leverage Hono's built-in route parameter validation or a custom validator middleware."],"tags":["validation","user-input","dns","ssrf-prevention","solidot"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}