{"record":{"id":"7d71e382e0b483c5","repo":"pot-app/pot-desktop","slug":"get-status-error-json-stringify-result","errorCode":null,"errorMessage":"Get Status Error: ${JSON.stringify(result)}","messagePattern":"Get Status Error: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/window/Config/pages/Backup/utils/aliyun.jsx","lineNumber":135,"sourceCode":"    }\n}\n\nexport async function status(sid) {\n    const res = await fetch(`https://openapi.alipan.com/oauth/qrcode/${sid}/status`);\n\n    if (res.ok) {\n        const result = res.data;\n        if (result['status']) {\n            return { status: result['status'], code: result['authCode'] };\n        } else {\n            throw new Error(`Can not find status: ${JSON.stringify(result)}`);\n        }\n    } else {\n        const result = res.data;\n        if (result['message']) {\n            throw new Error(result['message']);\n        } else {\n            throw new Error(`Get Status Error: ${JSON.stringify(result)}`);\n        }\n    }\n}\n\nexport async function userInfo(token) {\n    const res = await fetch('https://openapi.alipan.com/oauth/users/info', {\n        headers: {\n            Authorization: `Bearer ${token}`,\n        },\n    });\n    if (res.ok) {\n        const result = res.data;\n        if (result.hasOwnProperty('avatar') && result.hasOwnProperty('name')) {\n            return { avatar: result['avatar'], name: result['name'] };\n        } else {\n            throw new Error(`Can not find avatar or name: ${JSON.stringify(result)}`);\n        }\n    } else {","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/pot-app/pot-desktop/blob/594d32ede96acd106b0256deaa8bb440ffcdff40/src/window/Config/pages/Backup/utils/aliyun.jsx#L117-L153","documentation":"Fallback error in status(): the HTTP response was not ok AND the error body contained no `message` field, so the raw response body is stringified into `Get Status Error: <JSON>`. It means the QR-status poll failed with an unrecognizable error response.","triggerScenarios":"Calling status(sid) when the endpoint returns a non-2xx response whose res.data has no `message` key — e.g. HTML error page from a gateway, empty body, or differently-shaped error JSON.","commonSituations":"Alipan outage or CDN/WAF block returning HTML; network middleware altering responses; rate limiting with non-JSON bodies; sid containing characters that broke the URL so a gateway returned an error page.","solutions":["Inspect the stringified body in the error to identify the responder (gateway vs API).","Retry with backoff; transient 5xx/gateway errors usually clear.","Regenerate the QR session via qrcode() and retry the login flow.","Check network/proxy/firewall access to openapi.alipan.com from the app environment."],"exampleFix":"// before\nthrow new Error(`Get Status Error: ${JSON.stringify(result)}`);\n// after\nconsole.error('status poll failed', res.status, result);\nawait new Promise((r) => setTimeout(r, 2000)); // backoff\nreturn status(sid); // or regenerate sid via qrcode() if 4xx","handlingStrategy":"retry","validationCode":"// preflight connectivity check before polling\nconst ok = await fetch(`https://openapi.alipan.com/oauth/qrcode/${encodeURIComponent(sid)}/status`)\n  .then(r => r.ok).catch(() => false);\nif (!ok) await waitForNetwork();","typeGuard":"function isGatewayError(result) {\n  return typeof result === 'string' && result.trim().startsWith('<'); // HTML page, not JSON\n}","tryCatchPattern":"try {\n  const { status } = await status(sid);\n} catch (e) {\n  if (String(e.message).startsWith('Get Status Error')) {\n    // opaque non-2xx: backoff and retry, or new session after N failures\n    await sleep(2000 * attempt);\n    if (attempt < 3) return status(sid);\n    restartQrLogin();\n  }\n}","preventionTips":["Poll with exponential backoff instead of fixed intervals","Cap retries and regenerate the QR session after repeated opaque failures","Check proxy/firewall access to openapi.alipan.com in restricted environments","Include the HTTP status in logs alongside the stringified body"],"tags":["network","oauth","api-response","alipan"],"backgroundTag":"api-error-response-missing-message","analyzedSha":"594d32ede96acd106b0256deaa8bb440ffcdff40","analyzedAt":"2026-09-02T18:12:21.811Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}