DIYgod/RSSHub · error · InvalidParameterError

Invalid name

Error message

Invalid name

What it means

Thrown by the Lofter user handler (lib/routes/lofter/user.ts:31) as an `InvalidParameterError` when the `:name` path parameter fails `isValidHost()`. The name is interpolated into a subdomain (`${name}.lofter.com`), so it must be a valid DNS label.

Source

Thrown at lib/routes/lofter/user.ts:31

    parameters: { name: 'Lofter user name, can be found in the URL' },
    features: {
        requireConfig: false,
        requirePuppeteer: false,
        antiCrawler: false,
        supportBT: false,
        supportPodcast: false,
        supportScihub: false,
    },
    name: 'User',
    maintainers: ['hondajojo', 'nczitzk', 'LucunJi'],
    handler,
};

async function handler(ctx) {
    const name = ctx.req.param('name') ?? 'i';
    const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : '50';
    if (!isValidHost(name)) {
        throw new InvalidParameterError('Invalid name');
    }

    const rootUrl = `${name}.lofter.com`;

    const response = await got({
        method: 'post',
        url: 'http://api.lofter.com/v2.0/blogHomePage.api?product=lofter-iphone-10.0.0',
        body: new URLSearchParams({
            blogdomain: rootUrl,
            checkpwd: '1',
            following: '0',
            limit: String(limit),
            method: 'getPostLists',
            needgetpoststat: '1',
            offset: '0',
            postdigestnew: '1',
            supportposttypes: '1,2,3,4,5,6',
        }),

View on GitHub (pinned to bed535e087)

Solutions

  1. Pass only the bare subdomain label, e.g. `/lofter/user/i` (the documented default).
  2. Strip protocol/host/path from the value before calling the route.
  3. Verify `<name>.lofter.com` resolves in a browser.

Example fix

// before: GET /lofter/user/myblog.lofter.com
// after:  GET /lofter/user/myblog
Defensive patterns

Strategy: validation

Validate before calling

import { isValidHost } from '@/utils/valid-host';
function resolveLofterUserName(name: string | undefined): string {
    const n = (name ?? 'i').trim();
    if (!isValidHost(n)) throw new TypeError(`Invalid Lofter user name: '${name}'`);
    return n;
}

Type guard

function isLofterUserName(value: string): boolean {
    return /^[a-z0-9-]+$/i.test(value) && !value.includes('.');
}

Try / catch

import { InvalidParameterError } from '@/errors/types/invalid-parameter';
try {
    await fetchLofterUser(name);
} catch (e) {
    if (e instanceof InvalidParameterError && /Invalid name/.test(e.message)) {
        return { error: `Pass a bare subdomain label, not '${name}'` };
    }
    throw e;
}

Prevention

When it happens

Trigger: Requesting `/lofter/user/<name>/...` where `<name>` contains dots, slashes, spaces, or other invalid hostname characters; passing a full URL or blog path instead of the bare subdomain label.

Common situations: Passing `name.lofter.com` instead of `name`; trailing slash; uppercase; underscores.

Related errors


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