DIYgod/RSSHub · error · Error

article api error

Error message

article api error

What it means

Same `apiSuccessAssert` helper as news.ts, used by the SCUT JWC notice route. Throws `'article api error'` when an article detail API responds with `success: false`. A single failing article aborts the entire feed generation.

Source

Thrown at lib/routes/scut/jwc/notice.ts:44

};

const generateArticlePubDate = (createDateStr) => {
    const date = new Date(createDateStr);
    date.setHours(8);
    date.setMinutes(0);
    date.setSeconds(0);
    date.setMilliseconds(0);

    return timezone(date, 8);
};

const isRedirectPage = (data) => !!data.link;

const resolveRelativeUrl = (html) => html.replaceAll('src="/', () => `src="${new URL('.', baseUrl).href}`).replaceAll('href="/', () => `href="${new URL('.', baseUrl).href}`);

const apiSuccessAssert = (data) => {
    if (!data.success) {
        throw new Error('article api error');
    }
};

const generateArticleLink = (id) => `<p>链接:<a href="${getArticleUrlById(id)}">电脑版</a>&nbsp;|&nbsp;<a href="${getArticleMobileUrlById(id)}">手机版</a></p>`;

const generateArticleFullText = (data) => resolveRelativeUrl(data.content) + generateArticleLink(data.id);

export const route: Route = {
    path: '/jwc/notice/:category?',
    categories: ['university'],
    example: '/scut/jwc/notice/all',
    parameters: { category: '通知分类,默认为 `all`' },
    features: {
        requireConfig: false,
        requirePuppeteer: false,
        antiCrawler: false,
        supportBT: false,
        supportPodcast: false,

View on GitHub (pinned to bed535e087)

Solutions

  1. Retry shortly — transient backend issues resolve themselves.
  2. Inspect the raw detail API response for the failing id to confirm whether `success` is genuinely false or the schema shifted.
  3. Patch the handler to tolerate `success: false` by filtering out the affected item rather than throwing.

Example fix

// before
if (!data.success) {
    throw new Error('article api error');
}

// after
if (!data.success) {
    return null;
}
// then filter nulls out of the items array
Defensive patterns

Strategy: try-catch

Validate before calling

const data = await fetchArticle(id);
if (!data?.success) return null;

Type guard

const isArticleSuccess = (d: unknown): boolean => Boolean((d as any)?.success);

Try / catch

try { apiSuccessAssert(data); } catch (e) {
    if (e instanceof Error && e.message === 'article api error') continue;
    throw e;
}

Prevention

When it happens

Trigger: Fetching notices for a category where one or more detail calls return `success: false` (deleted notice, permission-restricted, backend hiccup).

Common situations: Category contains a stale id pointing to a removed notice; SCUT backend in maintenance; rate limiting after a burst of detail requests.

Related errors


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