DIYgod/RSSHub · error · InvalidParameterError

Invalid YouTube channel ID. \nYou may want to use <code>/you

Error message

Invalid YouTube channel ID. \nYou may want to use <code>/youtube/user/:id</code> instead.

What it means

InvalidParameterError thrown by the YouTube channel handler when the :id segment fails isYouTubeChannelId, which tests the regex /^UC[\w-]{21}[AQgw]$/ (24 chars: 'UC' + 22 word/dash chars ending in A/Q/g/w). The message nudges users toward /youtube/user/:id, because a non-conforming id usually means the caller supplied a username or @handle instead of a canonical channel id.

Source

Thrown at lib/routes/youtube/channel.ts:68

    },
};

async function handler(ctx) {
    const id = ctx.req.param('id');

    // Parse route parameters
    const routeParams = ctx.req.param('routeParams');
    const params = new URLSearchParams(routeParams);

    // Get embed parameter
    const embed = !params.get('embed');

    // Get filterShorts parameter (default to true if not specified)
    const filterShortsStr = params.get('filterShorts');
    const filterShorts = [null, '', 'true'].includes(filterShortsStr);

    if (!isYouTubeChannelId(id)) {
        throw new InvalidParameterError('Invalid YouTube channel ID. \nYou may want to use <code>/youtube/user/:id</code> instead.');
    }

    const isJsonFeed = ctx.req.query('format') === 'json';

    const data = await callApi({
        googleApi: getDataByChannelIdGoogle,
        youtubeiApi: getDataByChannelIdYoutubei,
        params: { channelId: id, embed, filterShorts, isJsonFeed },
    });

    return data;
}

View on GitHub (pinned to bed535e087)

Solutions

  1. Provide a canonical UC... channel id (find it via the channel page source or the find-your-channel-id tool).
  2. If you only have a username, use /youtube/user/:username.
  3. If you have an @handle, use /youtube/user/@handle.
  4. If you have a custom URL (youtube.com/c/slug), use /youtube/c/:slug.
Defensive patterns

Strategy: validation

Validate before calling

const CHANNEL_ID_RE = /^UC[\w-]{21}[AQgw]$/;
function requireChannelId(id: string) {
    if (!CHANNEL_ID_RE.test(id)) {
        throw new InvalidParameterError(`"${id}" is not a UC... channel id. Use /youtube/user/:id for usernames/handles or /youtube/c/:slug for custom URLs.`);
    }
}

Type guard

function isYouTubeChannelId(id: string): boolean {
    return /^UC[\w-]{21}[AQgw]$/.test(id);
}

Prevention

When it happens

Trigger: A request to /youtube/channel/:id where id is a username (e.g. 'DIYgod'), an @handle ('@SomeHandle'), a custom URL ('c/...' slug), or a malformed/garbled channel id. The regex rejects all of these before any API call.

Common situations: Caller confused channel id with username/handle/custom URL; copied the wrong segment from a YouTube URL (e.g. used the /c/ slug); trailing/leading whitespace or URL-encoded characters in the segment.

Related errors


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