{"record":{"id":"8aa29ddb2fa0c283","repo":"pot-app/pot-desktop","slug":"get-qrcode-error-json-stringify-result","errorCode":null,"errorMessage":"Get QrCode Error: ${JSON.stringify(result)}","messagePattern":"Get QrCode Error: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/window/Config/pages/Backup/utils/aliyun.jsx","lineNumber":115,"sourceCode":"        method: 'POST',\n        body: Body.json({\n            client_id: 'bf56dd2dc03a4d3489e3dda05dd6d466',\n            scopes: ['user:base', 'file:all:read', 'file:all:write'],\n        }),\n    });\n    if (res.ok) {\n        const result = res.data;\n        if (result['qrCodeUrl'] && result['sid']) {\n            return { url: result['qrCodeUrl'], sid: result['sid'] };\n        } else {\n            throw new Error(`Can not find qrCodeUrl: ${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 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']);","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/pot-app/pot-desktop/blob/594d32ede96acd106b0256deaa8bb440ffcdff40/src/window/Config/pages/Backup/utils/aliyun.jsx#L97-L133","documentation":"The aliyun.jsx qrcode() helper requests a login QR code from Alipan's OAuth endpoint (https://openapi.alipan.com/oauth/authorize/qrcode). When the HTTP response is not ok and the error body contains no `message` field, the code falls back to throwing `Get QrCode Error: <raw body JSON>`. It means the QR-code request failed with an unexpected response shape (no usable error message returned by the API).","triggerScenarios":"Calling qrcode() and the POST to openapi.alipan.com/oauth/authorize/qrcode returns a non-2xx status whose res.data lacks a `message` key (e.g. HTML error page, empty body, proxy/gateway error JSON with different field names).","commonSituations":"Alipan API downtime or rate limiting returning an HTML/CDN error page; a corporate proxy or firewall intercepting the request; the hardcoded client_id being revoked or the API contract changing; DNS/network failure inside the Tauri HTTP client producing an opaque error payload.","solutions":["Retry the QR-code request; transient gateway errors usually resolve on retry.","Inspect the JSON in the error message to identify the actual failure (status code, blocked request, etc.).","Check network/proxy settings — the Tauri HTTP client must be able to reach openapi.alipan.com.","Verify the Alipan OAuth API still returns errors with a `message` field; update the parser if the API contract changed."],"exampleFix":"// before\nthrow new Error(`Get QrCode Error: ${JSON.stringify(result)}`);\n// after\nif (res.status === 429 || res.status >= 500) {\n    // retry with backoff before giving up\n    return retryQrcode();\n}\nthrow new Error(`Get QrCode Error (HTTP ${res.status}): ${JSON.stringify(result)}`);","handlingStrategy":"try-catch","validationCode":"// before calling qrcode(), verify connectivity to the API\nconst reachable = await fetch('https://openapi.alipan.com').then(r => true).catch(() => false);\nif (!reachable) throw new Error('openapi.alipan.com unreachable — check network/proxy');","typeGuard":"function isQrCodeResponse(r) {\n  return r && typeof r === 'object' && typeof r.qrCodeUrl === 'string' && typeof r.sid === 'string';\n}","tryCatchPattern":"try {\n  const { url, sid } = await qrcode();\n  showQr(url);\n} catch (e) {\n  if (String(e.message).startsWith('Get QrCode Error')) {\n    // non-2xx without API message: transient/gateway — retry with backoff\n    await sleep(2000);\n    retryQrcode();\n  } else {\n    showError(e.message);\n  }\n}","preventionTips":["Retry QR-code requests with exponential backoff before surfacing the error","Check network/proxy reachability of openapi.alipan.com on app startup","Log the stringified body plus HTTP status for diagnosis","Keep the client_id/scope payload in sync with the current Alipan OAuth API contract"],"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"}