pot-app/pot-desktop · error · Error

Get UserInfo Error: ${JSON.stringify(result)}

Error message

Get UserInfo Error: ${JSON.stringify(result)}

What it means

Fallback error in userInfo(): the users/info request returned non-2xx and the error body had no `message` field, so the raw body is stringified into `Get UserInfo Error: <JSON>`. The token check failed at the HTTP level with an unrecognizable error payload.

Source

Thrown at src/window/Config/pages/Backup/utils/aliyun.jsx:158

export async function userInfo(token) {
    const res = await fetch('https://openapi.alipan.com/oauth/users/info', {
        headers: {
            Authorization: `Bearer ${token}`,
        },
    });
    if (res.ok) {
        const result = res.data;
        if (result.hasOwnProperty('avatar') && result.hasOwnProperty('name')) {
            return { avatar: result['avatar'], name: result['name'] };
        } else {
            throw new Error(`Can not find avatar or name: ${JSON.stringify(result)}`);
        }
    } else {
        const result = res.data;
        if (result['message']) {
            throw new Error(result['message']);
        } else {
            throw new Error(`Get UserInfo Error: ${JSON.stringify(result)}`);
        }
    }
}

export async function accessToken(code) {
    const res = await fetch('https://pot-app.com/api/ali_access_token', {
        method: 'POST',
        body: Body.json({
            code,
            refresh_token: '',
        }),
    });
    if (res.ok) {
        const result = res.data;
        if (result['access_token']) {
            return result['access_token'];
        } else {
            throw new Error(`Can not find access_token: ${JSON.stringify(result)}`);

View on GitHub (pinned to 594d32ede9)

Solutions

  1. Inspect the stringified body and HTTP status to identify the responder.
  2. Re-authenticate via qrcode()/accessToken() to get a fresh token.
  3. Check network/proxy access to openapi.alipan.com.
  4. Retry with backoff in case of a transient 5xx.

Example fix

// before
throw new Error(`Get UserInfo Error: ${JSON.stringify(result)}`);
// after
if (res.status === 401) {
    throw new Error('Token rejected (401) — re-authenticate via QR login');
}
throw new Error(`Get UserInfo Error (HTTP ${res.status}): ${JSON.stringify(result)}`);
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight: token present and endpoint reachable
const reachable = await fetch('https://openapi.alipan.com/oauth/users/info', {
  method: 'HEAD',
}).then(r => r.status !== 0).catch(() => false);
if (!reachable || !token) await reAuthenticate();

Type guard

function isUnauthorizedStatus(status) {
  return status === 401 || status === 403;
}

Try / catch

try {
  const { avatar, name } = await userInfo(token);
} catch (e) {
  if (String(e.message).startsWith('Get UserInfo Error')) {
    // opaque rejection — assume bad token, re-authenticate
    token = await fullQrLoginFlow();
    return userInfo(token);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling userInfo(token) when openapi.alipan.com/oauth/users/info returns a non-2xx response whose res.data lacks `message` — e.g. 401 with an empty body, an HTML/WAF block page, or gateway error JSON.

Common situations: Completely invalid token format rejected before API error JSON is produced; network/proxy interception; Alipan service disruption; clock skew causing premature token rejection in some gateways.

Related errors


AI-assisted analysis of pot-app/pot-desktop@594d32ede9 (2026-09-02). Data as JSON: /api/errors/ddaf8905238187cc. Report an issue: GitHub.