DIYgod/RSSHub · error · InvalidParameterError
Invalid type
Error message
Invalid type
What it means
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.
Source
Thrown at lib/routes/solidot/main.ts:61
},
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: '最新消息',
maintainers: ['sgqy', 'hang333', 'TonyRL'],
handler,
};
async function handler(ctx) {
const type = ctx.req.param('type') ?? 'www';
if (!isValidHost(type)) {
throw new InvalidParameterError('Invalid type');
}
const base_url = `https://${type}.solidot.org`;
const response = await got({
method: 'get',
url: base_url,
});
const data = response.data; // content is html format
const $ = load(data);
// get urls
const a = $('div.block_m').find('div.bg_htit > h2 > a');
const urls = Array.from(a, (element) => $(element).attr('href'));
// get articles
const msg_list = await Promise.all(urls.map((u) => cache.tryGet(u!, () => get_article(u))));
// feed the dataView on GitHub (pinned to bed535e087)
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.
Example fix
// before GET /solidot/tech_news // after GET /solidot/technology
Defensive patterns
Strategy: validation
Validate before calling
const VALID_TYPES = ['www', 'startup', 'linux', 'science', 'technology', 'mobile', 'apple', 'hardware', 'software', 'security', 'games', 'books', 'ask', 'idle', 'blog', 'cloud', 'story'];
const type = ctx.req.param('type') ?? 'www';
if (!VALID_TYPES.includes(type)) {
throw new InvalidParameterError(`Invalid type. Valid types: ${VALID_TYPES.join(', ')}`);
} Type guard
function isValidSolidotType(t: string | undefined): boolean {
if (!t) return true;
return isValidHost(t);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: User types a section name that doesn't match the documented options; URL encoding produces unexpected characters; or a scanner probes with arbitrary paths.
Related errors
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/bb3ff1d64d4cf409.
Report an issue: GitHub.