DIYgod/RSSHub · warning · InvalidParameterError
Invalid community: ${community}
Error message
Invalid community: ${community} What it means
Thrown by the lemmy route handler as InvalidParameterError when the `community` path param does not contain exactly one '@' — i.e. it is not in the required name@instance format. The handler splits on '@' and requires exactly 2 parts; any other count (0 or 2+ '@' signs) is rejected before any network call.
Source
Thrown at lib/routes/lemmy/index.ts:68
},
],
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: 'Community',
maintainers: ['wb14123', 'pseudoyu'],
handler,
};
async function handler(ctx) {
const sort = ctx.req.param('sort') ?? 'Active';
const community = ctx.req.param('community');
const communitySlices = community.split('@');
if (communitySlices.length !== 2) {
throw new InvalidParameterError(`Invalid community: ${community}`);
}
const instance = community.split('@', 2)[1];
const allowedDomain = ['lemmy.world', 'lemm.ee', 'lemmy.ml', 'sh.itjust.works', 'feddit.de', 'hexbear.net', 'beehaw.org', 'lemmynsfw.com', 'lemmy.ca', 'programming.dev'];
if (!config.feature.allow_user_supply_unsafe_domain && !allowedDomain.includes(new URL(`http://${instance}/`).hostname)) {
throw new ConfigNotFoundError(`This RSS is disabled unless 'ALLOW_USER_SUPPLY_UNSAFE_DOMAIN' is set to 'true'.`);
}
const communityUrl = `https://${instance}/api/v3/community?name=${community}`;
const communityData = await cache.tryGet(communityUrl, async () => {
const result = await got({ method: 'get', url: communityUrl, headers: { 'Content-Type': 'application/json' } });
return result.data.community_view.community;
});
const postUrl = `https://${instance}/api/v3/post/list?type_=All&sort=${sort}&community_name=${community}&limit=50`;
const postData = await cache.tryGet(
postUrl,
async () => {
const result = await got({ method: 'get', url: postUrl, headers: { 'Content-Type': 'application/json' } });View on GitHub (pinned to bed535e087)
Solutions
- Provide the community in name@instance form, e.g. /lemmy/programming@programming.dev/Hot
- If you want a default instance, wrap the route or pre-process the param before calling the handler
- Validate/normalize the param at the proxy layer for self-hosters
- Check for URL-encoded '@' (%40) if the literal isn't coming through
Example fix
// before
const communitySlices = community.split('@');
if (communitySlices.length !== 2) {
throw new InvalidParameterError(`Invalid community: ${community}`);
}
// after — clearer message + accept %40
const normalized = community.replaceAll('%40', '@');
const communitySlices = normalized.split('@');
if (communitySlices.length !== 2) {
throw new InvalidParameterError(`Invalid community '${community}'. Expected format: name@instance (e.g. programming@programming.dev)`);
} Defensive patterns
Strategy: validation
Validate before calling
function parseCommunity(raw: string): { name: string; instance: string } {
const norm = raw.replaceAll('%40', '@');
const parts = norm.split('@');
if (parts.length !== 2 || !parts[0] || !parts[1]) {
throw new Error(`community '${raw}' must be name@instance`);
}
return { name: parts[0], instance: parts[1] };
} Type guard
function isCommunityFormat(v: unknown): v is string {
if (typeof v !== 'string') return false;
const parts = v.replaceAll('%40', '@').split('@');
return parts.length === 2 && parts[0].length > 0 && parts[1].length > 0;
} Try / catch
try { return await handler(ctx); }
catch (e) {
if (e instanceof InvalidParameterError && /Invalid community/.test(e.message)) {
return ctx.json({ error: e.message, format: 'name@instance' }, 400);
}
throw e;
} Prevention
- Normalize URL-encoded '@' (%40) before splitting
- Reject empty name or instance segments, not just wrong part count
- Provide example values in the error message
- Default to a known instance if your deployment wants one
When it happens
Trigger: Request to /lemmy/<community>/<sort> where <community> lacks the @instance suffix (e.g. 'programming' instead of 'programming@programming.dev'), or contains multiple '@' signs (e.g. 'a@b@c'). The split must yield exactly ['name','instance'].
Common situations: User omits the instance (most common — many users assume a default instance); copy-paste truncates the community name; URL encoding mangles the '@' (e.g. %40 handled differently); trailing slash creating an empty segment.
Related errors
- Bad timeRange range. See <a href="https://docs.rsshub.app/ro
- Bad parameter. See <a href="https://docs.rsshub.app/routes/g
- Invalid city
- Invalid channel name
- This category does not exist. Please refer to the documentat
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/ec04b732d7d6776f.
Report an issue: GitHub.