DIYgod/RSSHub · error · Error

each.message

Error message

each.message

What it means

The SICAU second-class activities route issues two paginated queries in parallel and checks each response: if `each.code !== '0'` it throws `each.message`, propagating the upstream API's own error text. Code `'0'` is the SICAU API's success sentinel; any other value indicates a backend-side error (invalid gid/typeId, auth, rate limit).

Source

Thrown at lib/routes/sicau/jk.ts:96

            baseURL: 'https://jk.sicau.edu.cn/act/actInfo/v1.0.0',
            headers: { 'x-access-token': token },
            method: 'post',
        });
        const query = async (page: number) =>
            await $post('/getUserSchoolActList', {
                query: {
                    gid: gidDict[gid],
                    typeId: typeDict[typeId],
                    sortType,
                    page,
                },
            });

        const res = await Promise.all([query(1), query(2)]);

        for (const each of res) {
            if (each.code !== '0') {
                throw new Error(each.message);
            }
        }

        const list: DataItem[] = [...res[0].content, ...res[1].content]
            .filter((e) => e.statusName !== '待发学时')
            .map((each) => ({
                id: each.id,
                guid: each.id,
                title: each.title,
                image: each.logo,
            }));

        const items = await Promise.all(
            list.map((item) =>
                cache.tryGet(String(item.id), async () => {
                    const { code, message, content } = await $post(`/getActDetail?actId=${item.id}`);
                    if (code === '0') {
                        item.author = content.groupName;

View on GitHub (pinned to bed535e087)

Solutions

  1. Verify the `:gid` and `:typeId` path parameters against the documented values in lib/routes/sicau/jk.ts (check `gidDict` and `typeDict`).
  2. Retry shortly to rule out transient upstream errors.
  3. If the API contract changed, inspect the raw response to see the new error code/message and update the dicts accordingly.

Example fix

// before
/rsshub/sicau/jk/<bad-gid>/<bad-type>

// after
/rsshub/sicau/jk/<valid-gid>/<valid-type>
Defensive patterns

Strategy: try-catch

Validate before calling

const res = await Promise.all([query(1), query(2)]);
for (const each of res) {
    if (each.code !== '0') {
        return ctx.body(`Upstream SICAU API error: ${each.message}`, 502);
    }
}

Type guard

const isUpstreamOk = (r: unknown): boolean => (r as any)?.code === '0';

Try / catch

try {
    for (const each of res) apiSuccessAssert(each);
} catch (e) {
    if (e instanceof Error && /upstream/.test(e.message)) { /* degrade gracefully */ }
    throw e;
}

Prevention

When it happens

Trigger: A request to /sicau/jk/... where the upstream `/getUserSchoolActList` endpoint returns a non-zero code on either page 1 or page 2. Common when `gidDict[gid]` or `typeDict[typeId]` resolves to an invalid upstream id, or the API token/session is missing.

Common situations: Invalid gid/typeId path parameters; upstream API changed its code semantics; SICAU enabled auth or geographic restrictions; transient backend error.

Related errors


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