{"record":{"id":"624a79616451d659","repo":"DIYgod/RSSHub","slug":"something-wrong","errorCode":null,"errorMessage":"something wrong","messagePattern":"something wrong","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/routes/zsxq/utils.ts","lineNumber":24,"sourceCode":"import type { BasicResponse, ResponseData, Topic, TopicImage } from './types';\n\nexport async function customFetch<T extends BasicResponse<ResponseData>>(path: string, retryCount = 0): Promise<T['resp_data']> {\n    const apiUrl = 'https://api.zsxq.com/v2';\n\n    const response = await got(apiUrl + path, {\n        headers: {\n            cookie: `zsxq_access_token=${config.zsxq.accessToken};`,\n        },\n    });\n    const { succeeded, code, resp_data } = response.data as T;\n    if (succeeded) {\n        return resp_data;\n    }\n    // sometimes the request will fail with code 1059, retry will solve the problem\n    if (code === 1059 && retryCount < 3) {\n        return customFetch(path, retryCount + 1);\n    }\n    throw new Error('something wrong');\n}\n\nfunction parseTopicContent(text: string = '', images: TopicImage[] = []) {\n    let result = text.replaceAll('\\n', '<br>');\n    result = result.replaceAll(/<e type=\"web\" href=\"(.*?)\" title=\"(.*?)\" style=\"(.*?)\" \\/>/g, (_, p1, p2) => `<a href=${decodeURIComponent(p1)}>${decodeURIComponent(p2)}</a>`);\n    result = result.replaceAll(/<e type=\"hashtag\".*?title=\"(.*?)\" \\/>/g, (_, p1) => {\n        const title = decodeURIComponent(p1);\n        return `<span>${title}</span>`;\n    });\n    result += images.map((image) => `<img src=\"${image.original?.url ?? image.large?.url ?? image.thumbnail?.url}\">`).join('<br>');\n    return result;\n}\n\nexport function generateTopicDataItem(topics: Topic[]): DataItem[] {\n    return topics.map((topic) => {\n        let description: string | undefined;\n        let title = '';\n        const url = `https://wx.zsxq.com/topic/${topic.topic_id}`;","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/zsxq/utils.ts#L6-L42","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Refresh ZSXQ_ACCESS_TOKEN from a fresh wx.zsxq.com cookie (most common cause).","Log response.data.code (and any info field) right before the throw to identify the real failure.","Improve the error to include the code: throw new Error(`zsxq API error code ${code}`);.","Confirm the requested group/user id exists and the token's account can access it."],"exampleFix":"// before\nif (code === 1059 && retryCount < 3) {\n    return customFetch(path, retryCount + 1);\n}\nthrow new Error('something wrong');\n// after\nif (code === 1059 && retryCount < 3) {\n    return customFetch(path, retryCount + 1);\n}\nthrow new Error(`zsxq API error (code ${code}) for ${path}`);","handlingStrategy":"try-catch","validationCode":"// pre-flight: token shape check (zsxq tokens are long numeric-ish strings)\nimport { config } from '@/config';\nfunction looksLikeZsxqToken(t?: string): boolean {\n  return typeof t === 'string' && t.length > 20 && /^[-\\w]+$/.test(t);\n}\nif (!looksLikeZsxqToken(config.zsxq?.accessToken)) {\n  console.warn('ZSXQ_ACCESS_TOKEN looks invalid — expect API errors.');\n}","typeGuard":"function isZsxqApiError(e: unknown, code?: number): e is Error {\n  return e instanceof Error && /something wrong|zsxq API error/i.test(e.message);\n}","tryCatchPattern":"try {\n  return await customFetch<T>(path);\n} catch (e) {\n  // the bare 'something wrong' hides response.data.code — log it before throwing\n  console.error('zsxq customFetch failed for', path, e);\n  throw e;\n}\n// better: improve the throw inside customFetch to include response.data.code","preventionTips":["Refresh the token proactively before it rotates out.","Patch customFetch to include response.data.code in the error message for diagnosability.","Confirm the target group/user id is accessible to the token's account."],"tags":["api","zsxq","error-handling","observability","rsshub"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}