DIYgod/RSSHub · error

something wrong

Error message

something wrong

What it means

A generic catch-all thrown by customFetch in lib/routes/zsxq/utils.ts when the zsxq API returns succeeded:false with an error code that is NOT 1059 (the only retried transient code). The actual failure code in response.data.code is discarded, so auth failures, rate limits, permission errors and invalid ids all surface as the unhelpful literal 'something wrong'.

Source

Thrown at lib/routes/zsxq/utils.ts:24

import type { BasicResponse, ResponseData, Topic, TopicImage } from './types';

export async function customFetch<T extends BasicResponse<ResponseData>>(path: string, retryCount = 0): Promise<T['resp_data']> {
    const apiUrl = 'https://api.zsxq.com/v2';

    const response = await got(apiUrl + path, {
        headers: {
            cookie: `zsxq_access_token=${config.zsxq.accessToken};`,
        },
    });
    const { succeeded, code, resp_data } = response.data as T;
    if (succeeded) {
        return resp_data;
    }
    // sometimes the request will fail with code 1059, retry will solve the problem
    if (code === 1059 && retryCount < 3) {
        return customFetch(path, retryCount + 1);
    }
    throw new Error('something wrong');
}

function parseTopicContent(text: string = '', images: TopicImage[] = []) {
    let result = text.replaceAll('\n', '<br>');
    result = result.replaceAll(/<e type="web" href="(.*?)" title="(.*?)" style="(.*?)" \/>/g, (_, p1, p2) => `<a href=${decodeURIComponent(p1)}>${decodeURIComponent(p2)}</a>`);
    result = result.replaceAll(/<e type="hashtag".*?title="(.*?)" \/>/g, (_, p1) => {
        const title = decodeURIComponent(p1);
        return `<span>${title}</span>`;
    });
    result += images.map((image) => `<img src="${image.original?.url ?? image.large?.url ?? image.thumbnail?.url}">`).join('<br>');
    return result;
}

export function generateTopicDataItem(topics: Topic[]): DataItem[] {
    return topics.map((topic) => {
        let description: string | undefined;
        let title = '';
        const url = `https://wx.zsxq.com/topic/${topic.topic_id}`;

View on GitHub (pinned to bed535e087)

Solutions

  1. Refresh ZSXQ_ACCESS_TOKEN from a fresh wx.zsxq.com cookie (most common cause).
  2. Log response.data.code (and any info field) right before the throw to identify the real failure.
  3. Improve the error to include the code: throw new Error(`zsxq API error code ${code}`);.
  4. Confirm the requested group/user id exists and the token's account can access it.

Example fix

// before
if (code === 1059 && retryCount < 3) {
    return customFetch(path, retryCount + 1);
}
throw new Error('something wrong');
// after
if (code === 1059 && retryCount < 3) {
    return customFetch(path, retryCount + 1);
}
throw new Error(`zsxq API error (code ${code}) for ${path}`);
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight: token shape check (zsxq tokens are long numeric-ish strings)
import { config } from '@/config';
function looksLikeZsxqToken(t?: string): boolean {
  return typeof t === 'string' && t.length > 20 && /^[-\w]+$/.test(t);
}
if (!looksLikeZsxqToken(config.zsxq?.accessToken)) {
  console.warn('ZSXQ_ACCESS_TOKEN looks invalid — expect API errors.');
}

Type guard

function isZsxqApiError(e: unknown, code?: number): e is Error {
  return e instanceof Error && /something wrong|zsxq API error/i.test(e.message);
}

Try / catch

try {
  return await customFetch<T>(path);
} catch (e) {
  // the bare 'something wrong' hides response.data.code — log it before throwing
  console.error('zsxq customFetch failed for', path, e);
  throw e;
}
// better: improve the throw inside customFetch to include response.data.code

Prevention

When it happens

Trigger: Expired or invalid access token (auth rejection); requesting a private group the token owner cannot read; rate limiting; invalid group/user id; any zsxq API error code other than 1059 after up to 3 retries.

Common situations: zsxq tokens expire/rotate — a previously working feed starts failing; user requests a group they are not a member of; zsxq introduces a new error code that the shim does not handle.

Related errors


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