{"record":{"id":"50f403b4d70e6128","repo":"pot-app/pot-desktop","slug":"can-not-find-status-json-stringify-result","errorCode":null,"errorMessage":"Can not find status: ${JSON.stringify(result)}","messagePattern":"Can not find status: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/window/Config/pages/Backup/utils/aliyun.jsx","lineNumber":128,"sourceCode":"    } else {\n        const result = res.data;\n        if (result['message']) {\n            throw new Error(result['message']);\n        } else {\n            throw new Error(`Get QrCode Error: ${JSON.stringify(result)}`);\n        }\n    }\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) {","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/pot-app/pot-desktop/blob/594d32ede96acd106b0256deaa8bb440ffcdff40/src/window/Config/pages/Backup/utils/aliyun.jsx#L110-L146","documentation":"The status() helper polls https://openapi.alipan.com/oauth/qrcode/{sid}/status while the user scans the login QR code. If the response is HTTP-ok but the body has no `status` field, the code throws `Can not find status: <body JSON>`. It indicates the API returned 200 with an unexpected payload shape.","triggerScenarios":"Calling status(sid) with an HTTP 200 response whose res.data lacks `status` — e.g. an expired/invalid sid returning an empty or error-shaped object, or the endpoint's response schema changing.","commonSituations":"Polling with a stale sid after the QR session expired; the QR session was consumed/cancelled and the API returns a 200 with no status; a version change of the Alipan OAuth API that renamed the `status` field.","solutions":["Log the JSON in the error to see what the endpoint actually returned.","Re-run qrcode() to obtain a fresh sid and restart the login flow when the session is expired.","Treat this as 'session expired/invalid' in the polling loop and stop polling instead of crashing.","Check for Alipan OAuth API schema changes and update field expectations."],"exampleFix":"// before\nif (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// after\nif (result && typeof result.status === 'string') {\n    return { status: result.status, code: result.authCode };\n}\nreturn { status: 'expired' }; // treat missing status as expired session, refresh sid via qrcode()","handlingStrategy":"validation","validationCode":"// validate the poll result before trusting it\nfunction hasStatus(data) {\n  return data && typeof data === 'object' && typeof data.status === 'string' && data.status.length > 0;\n}\n// use: if (hasStatus(res.data)) { ... } else { regenerate sid via qrcode() }","typeGuard":"function isQrStatusResponse(r) {\n  return r && typeof r === 'object' && typeof r.status === 'string';\n}","tryCatchPattern":"try {\n  const { status, code } = await status(sid);\n  if (status === 'LoginSuccess') finishLogin(code);\n} catch (e) {\n  if (String(e.message).startsWith('Can not find status')) {\n    // missing status field = expired/invalid session — stop polling, get new QR\n    stopPolling();\n    restartQrLogin();\n  }\n}","preventionTips":["Bound the polling loop (e.g. max 2 minutes) and regenerate the sid on any anomaly","Treat a missing `status` field as 'session expired', not a crash","Re-fetch the QR code rather than reusing an old sid","Monitor Alipan OAuth API changelogs for schema changes"],"tags":["oauth","qr-login","response-shape","alipan"],"backgroundTag":"api-response-missing-field","analyzedSha":"594d32ede96acd106b0256deaa8bb440ffcdff40","analyzedAt":"2026-09-02T18:12:21.811Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}