DIYgod/RSSHub · warning · Error
Invalid team name
Error message
Invalid team name
What it means
Thrown by the Hupu NBA team news route when the `:team` path parameter does not match any key in `NBA_TEAMS_ID_MAP`. The handler looks up the team slug to obtain a numeric `teamId` used in the Hupu basketball API. If the slug is not found or the found entry lacks a `teamId`, the route throws a plain `Error` (not `InvalidParameterError`).
Source
Thrown at lib/routes/hupu/news.ts:25
import { getEntryDetails } from './utils';
export const route: Route = {
path: '/news/:team',
name: '队伍新闻',
url: 'm.hupu.com',
maintainers: ['hyoban'],
example: '/hupu/news/Spurs',
parameters: {
team: {
description: '全小写的英文队名,例如:spurs, lakers, warriors 等等',
},
},
categories: ['bbs'],
handler: async (ctx): Promise<Data> => {
const team = NBA_TEAMS_ID_MAP[ctx.req.param('team')!];
const teamId = team?.teamId;
if (!teamId) {
throw new Error('Invalid team name');
}
const data = await ofetch(`https://games.mobileapi.hupu.com/3/7.5.60/basketballapi/news/v2/teamNewsById?cateGoryCode=basketball&clientId=93977196&newsId=0&teamId=${teamId}`);
let items: DataItem[] = data.result.map((item) => ({
title: item.title,
guid: item.tid,
link: `https://m.hupu.com/bbs/${item.tid}`,
pubDate: timezone(parseDate(item.publishTime), 8),
}));
items = await Promise.all(items.map((item) => getEntryDetails(item)));
return {
title: `虎扑 - ${team.teamName} 新闻`,
link: 'https://m.hupu.com',
item: items,
} as Data;
},View on GitHub (pinned to bed535e087)
Solutions
- Check the `NBA_TEAMS_ID_MAP` keys in `lib/routes/hupu/consts.ts` for the exact valid slugs.
- Use lowercase team nicknames as documented (e.g. `spurs`, `lakers`, `warriors`, `celtics`).
- As a maintainer: switch to `InvalidParameterError` and list valid team names in the error message.
Example fix
// before (broken) // GET /hupu/news/SanAntonio // after (correct) // GET /hupu/news/spurs
Defensive patterns
Strategy: validation
Validate before calling
import { NBA_TEAMS_ID_MAP } from './consts';
function isValidTeam(team: string): boolean {
return Boolean(NBA_TEAMS_ID_MAP[team]?.teamId);
} Type guard
function isKnownNbaTeam(team: string): boolean {
return Boolean(NBA_TEAMS_ID_MAP[team]?.teamId);
} Prevention
- Use `InvalidParameterError` and list valid team slugs in the error message.
- Document that team names should be lowercase nicknames.
- Consider adding `parameters.options` listing all valid teams from `NBA_TEAMS_ID_MAP`.
When it happens
Trigger: Requesting `/hupu/news/<team>` where `<team>` is not a recognized NBA team slug in the `NBA_TEAMS_ID_MAP` constant. The description says to use lowercase English team names like `spurs`, `lakers`, `warriors`.
Common situations: Typo in the team name, using a city name instead of the team nickname (e.g. `san-antonio` instead of `spurs`), using a non-NBA team, or the team slug format differs from what's in the map (case sensitivity).
Related errors
- Invalid category. Valid options are: ${Object.keys(categorie
- Bad category. See <a href="https://docs.rsshub.app/routes/go
- Bad category. See <a href="https://docs.rsshub.app/routes/go
- Nanjing, Cannot find page
- Bad category. See <a href="https://docs.rsshub.app/routes/go
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/6650962e9225ac83.
Report an issue: GitHub.