{"record":{"id":"c2967ce45b64de13","repo":"DIYgod/RSSHub","slug":"cookies-expired-msg-resp-data-msg-r","errorCode":null,"errorMessage":"Cookies expired. Msg: ${resp?.data?.msg || ''} ${resp?.data?.url || ''}","messagePattern":"Cookies expired\\. Msg: (.+?) (.+?)","errorType":"exception","errorClass":"RenewWeiboCookiesError","httpStatus":503,"severity":"error","filePath":"lib/routes/weibo/utils.ts","lineNumber":126,"sourceCode":"                    if (times < 2 || !cookies) {\n                        throw new Error(`Unable to fetch visitor cookies. Please set WEIBO_COOKIES. Redirection: ${times}, last URL: ${page.url()}`);\n                    }\n                    return cookies;\n                })();\n\n                try {\n                    return await visitorCookiesPromise;\n                } finally {\n                    visitorCookiesPromise = undefined;\n                }\n            });\n        };\n    })(),\n    tryWithCookies: (() => {\n        let errors = 0;\n        const verifier = (resp: any): void => {\n            if (resp?.data?.ok === -100) {\n                throw new RenewWeiboCookiesError(`Cookies expired. Msg: ${resp?.data?.msg || ''} ${resp?.data?.url || ''}`);\n            }\n        };\n        return async <T>(callback: (cookies: string, verifier: (resp: any) => void) => Promise<T>): Promise<T> => {\n            try {\n                return await callback(await weiboUtils.getCookies(false), verifier);\n            } catch (error: any) {\n                if (error.message?.includes('WEIBO_COOKIES')) {\n                    throw error;\n                }\n                if (errors > 10) {\n                    logger.warn(`Too many errors while fetching data from weibo API, renewing Cookies: ${error.message}`);\n                    logger.info('Please open an issue on GitHub if renewing Cookies fixes the error');\n                } else if ((error.name === 'HTTPError' || error.name === 'FetchError') && error.status === 432) {\n                    // empty\n                } else if (error.name === 'RenewWeiboCookiesError') {\n                    // empty\n                } else {\n                    errors++;","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/weibo/utils.ts#L108-L144","documentation":"A RenewWeiboCookiesError raised by the response verifier whenever a weibo API call returns data.ok === -100, weibo's signal that the active cookies (cached visitor cookies or user-supplied WEIBO_COOKIES) are no longer valid. The msg/url from the response body are appended for diagnostics.","triggerScenarios":"verifier(resp) sees resp.data.ok === -100 on any weibo API response passed through tryWithCookies' callback, throwing at utils.ts:126. tryWithCookies then catches it and triggers a cookie renew.","commonSituations":"Cookies expired server-side; weibo invalidated the session (logout, security reset); visitor cookies were blacklisted; rate-limited into a soft-expiry state.","solutions":["If WEIBO_COOKIES is set, refresh it from a browser session (this error usually precedes error 620 when pinned cookies are used).","If relying on auto visitor cookies, confirm Playwright works (error 622) so the auto-renew triggered by this error can succeed.","Inspect the appended msg/url in the log to distinguish true expiry from a transient weibo-side error."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Inspect a sample API response before trusting the cookie path\nconst probe = await got('https://m.weibo.cn/feed/friends?max_id=0', { headers: { ...weiboUtils.apiHeaders, Cookie: cookies } });\nif (probe.data?.ok === -100) {\n    throw new Error('Weibo reports ok=-100 — cookies are already expired; do not proceed.');\n}","typeGuard":"function isRenewWeiboCookiesError(e: unknown): boolean {\n    return e instanceof Error && (e.name === 'RenewWeiboCookiesError' || /Cookies expired\\. Msg:/i.test(e.message));\n}","tryCatchPattern":"// tryWithCookies already handles one renew; at the caller, allow a bounded second attempt\ntry {\n    return await weiboUtils.tryWithCookies(cb);\n} catch (e) {\n    if (isRenewWeiboCookiesError(e)) {\n        // one renew already happened internally and failed; surface rather than loop\n        throw e;\n    }\n    throw e;\n}","preventionTips":["Wrap every weibo API call with the provided verifier so ok=-100 is caught uniformly.","Alert on RenewWeiboCookiesError frequency — a spike means cookies/IP are being invalidated.","Don't catch and swallow this error; let tryWithCookies drive the renew, then fail loudly if it persists."],"tags":["weibo","cookies","authentication","api"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}