DIYgod/RSSHub · warning · InvalidParameterError

Invalid site

Error message

Invalid site

What it means

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.

Source

Thrown at lib/routes/hedwig/posts.ts:32

});

export const route: Route = {
    path: '/posts/:site',
    categories: ['blog'],
    example: '/hedwig/posts/walnut',
    parameters: { site: '站点名,原则上只要是 `{site}.hedwig.pub` 都可以匹配' },
    features: {
        supportRadar: false,
    },
    name: 'Posts',
    url: 'hedwig.pub',
    maintainers: ['zwithz', 'GetToSet'],
    view: ViewType.Articles,
    handler: async (ctx) => {
        const { site } = ctx.req.param();

        if (!isValidHost(site)) {
            throw new InvalidParameterError('Invalid site');
        }

        const baseUrl = `https://${site}.hedwig.pub`;

        const response = await ofetch(baseUrl);
        const $ = load(response);

        const text = $('script#__NEXT_DATA__').text();
        const json = JSON.parse(text);

        const pageProps = json.props.pageProps;

        const list = pageProps.issuesByNewsletter.map((item) => {
            const description = item.blocks.map((block) => md.render(block.markdown.text)).join('');
            return {
                title: item.subject,
                description,
                pubDate: timezone(parseDate(item.publishAt, 'YYYY-MM-DDTHH:mm:ss.SSS[Z]'), 0),

View on GitHub (pinned to bed535e087)

Solutions

  1. Confirm the newsletter exists by visiting `https://<site>.hedwig.pub` in a browser.
  2. Check the spelling of the `:site` parameter — it must match the subdomain exactly.
  3. If the newsletter was removed, there is no fix other than choosing a different one.

Example fix

// before (broken)
// GET /hedwig/posts/nonexistent-newsletter

// after (correct)
// GET /hedwig/posts/walnut
Defensive patterns

Strategy: validation

Validate before calling

// The route already uses isValidHost(site) before the fetch.
// Callers can pre-check:
import { isValidHost } from '@/utils/valid-host';
if (!isValidHost(site)) {
    throw new InvalidParameterError('Invalid site');
}

Type guard

async function isValidHedwigSite(site: string): Promise<boolean> {
    // isValidHost already does DNS resolution
    const { isValidHost } = await import('@/utils/valid-host');
    return isValidHost(site);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/e1d1bfdd653441f5. Report an issue: GitHub.