pot-app/pot-desktop · error · Error
Can not find avatar or name: ${JSON.stringify(result)}
Error message
Can not find avatar or name: ${JSON.stringify(result)} What it means
The userInfo() helper calls https://openapi.alipan.com/oauth/users/info with the access token and expects `avatar` and `name` in a 200 response. If either property is missing, it throws `Can not find avatar or name: <body JSON>`, i.e. the token was accepted but the profile payload didn't match the expected shape.
Source
Thrown at src/window/Config/pages/Backup/utils/aliyun.jsx:151
throw new Error(result['message']);
} else {
throw new Error(`Get Status Error: ${JSON.stringify(result)}`);
}
}
}
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: '',
}),View on GitHub (pinned to 594d32ede9)
Solutions
- Check the JSON dump for which field is missing — if both, the token is likely invalid/limited.
- Re-authorize via the QR flow ensuring the `user:base` scope is requested (as qrcode() does).
- Verify the token is a fresh Alipan OAuth access token, not a refresh token or app token.
- Check for Alipan API schema changes and update the field checks.
Example fix
// before
if (result.hasOwnProperty('avatar') && result.hasOwnProperty('name')) {
return { avatar: result['avatar'], name: result['name'] };
}
// after
const avatar = result?.avatar ?? '';
const name = result?.name;
if (typeof name === 'string') {
return { avatar, name }; // tolerate missing avatar, require only name
} Defensive patterns
Strategy: validation
Validate before calling
// validate token scope/shape before calling userInfo
function looksLikeAccessToken(token) {
return typeof token === 'string' && token.split('.').length >= 2 && token.length > 20;
}
// ensure the QR flow requested the 'user:base' scope before exchanging for a token Type guard
function hasProfileFields(r) {
return r && typeof r === 'object' && typeof r.name === 'string' && ('avatar' in r);
} Try / catch
try {
const { avatar, name } = await userInfo(token);
} catch (e) {
if (String(e.message).startsWith('Can not find avatar or name')) {
// token accepted but profile incomplete — likely missing user:base scope
await reAuthorizeWithBaseScope();
} else {
showError(e.message);
}
} Prevention
- Always request the `user:base` scope in the QR authorization (as qrcode() does)
- Verify the access token is a fresh Alipan OAuth token before calling userInfo
- Degrade gracefully: require only `name`, tolerate a missing avatar
- Test the users/info response shape against the current Alipan API version
When it happens
Trigger: Calling userInfo(token) with an HTTP 200 whose res.data lacks `avatar` or `name` — e.g. the token was issued with insufficient scopes (missing user:base), or the users/info response schema changed.
Common situations: Authorizing with scopes that exclude user:base so the API omits profile fields; using a partially-valid token from a different account type; Alipan renaming fields in the OAuth users/info endpoint.
Related errors
- Can not find status: ${JSON.stringify(result)}
- Get QrCode Error: ${JSON.stringify(result)}
- Get Status Error: ${JSON.stringify(result)}
- Get UserInfo Error: ${JSON.stringify(result)}
- Can not find access_token: ${JSON.stringify(result)}
AI-assisted analysis of pot-app/pot-desktop@594d32ede9 (2026-09-02).
Data as JSON: /api/errors/d6f6175373cf10e5.
Report an issue: GitHub.