pot-app/pot-desktop · error · Error

Can not find url

Error message

Can not find url: ${JSON.stringify(result)}

What it means

getDownloadUrl calls the Alipan openAPI endpoint openFile/getDownloadUrl. If the HTTP response is ok (2xx) but the body does not contain a 'url' field, this error is thrown with the whole payload JSON-stringified. A 2xx response without 'url' means the API accepted the request semantics but did not return a download link (unusual response shape or partial success payload).

Solutions

  1. Log the JSON.stringify(result) embedded in the error to see the actual payload keys returned by the API.
  2. Confirm drive_id and file_id are a matching pair (fetch file_id with getFileByPath on the same drive_id).
  3. Check whether the file is in the recycle bin and restore it, or re-upload the backup.
  4. Update parsing to the current Alipan openAPI response schema if it changed.
  5. Retry; if the API occasionally returns envelopes without url, treat missing url as retryable.

Example fix

// before
if (result['url']) {
    return result['url'];
} else {
    throw new Error(`Can not find url: ${JSON.stringify(result)}`);
}
// after
const url = result['url'] ?? result?.data?.url;
if (url) return url;
if (result['code'] === 'NotFound.File') return null; // handle missing file
throw new Error(`getDownloadUrl: no url in response (HTTP ${res.status}): ${JSON.stringify(result)}`);
Defensive patterns

Strategy: type-guard

Validate before calling

if (!file_id) throw new Error('file_id is required by getDownloadUrl');
if (!drive_id) throw new Error('drive_id is required by getDownloadUrl');

Type guard

function isDownloadUrlResponse(data) {
    return typeof data === 'object' && data !== null && typeof data.url === 'string' && data.url.length > 0;
}

Try / catch

try {
    const url = await getDownloadUrl(token, drive_id, fileId);
} catch (e) {
    if (e.message.startsWith('Can not find url')) {
        // payload logged inside the error; verify drive_id/file_id pairing,
        // check recycle bin, or re-fetch file_id before retrying
    }
    throw e;
}

Prevention

When it happens

Trigger: getDownloadUrl receives res.ok === true but result['url'] is undefined: e.g. the API returns a success envelope without a url because file_id exists in a different drive, the file is in recycle bin, or the response schema changed / is an error object delivered with a 2xx-wrapped body.

Common situations: Passing a file_id obtained from a different drive than drive_id; file was moved to trash so download link is withheld; Alipan API response schema update; incorrect parsing layer (res.data already unwrapped differently than expected by the HTTP client).

Related errors


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

Appendix: source

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

}

async function getDownloadUrl(token, drive_id, file_id) {
    const res = await fetch('https://openapi.alipan.com/adrive/v1.0/openFile/getDownloadUrl', {
        method: 'POST',
        headers: {
            Authorization: `Bearer ${token}`,
        },
        body: Body.json({
            drive_id,
            file_id,
        }),
    });
    if (res.ok) {
        const result = res.data;
        if (result['url']) {
            return result['url'];
        } else {
            throw new Error(`Can not find url: ${JSON.stringify(result)}`);
        }
    } else {
        const result = res.data;
        if (result['message']) {
            throw new Error(result['message']);
        } else {
            throw new Error(`Get accessToken Error: ${JSON.stringify(result)}`);
        }
    }
}

View on GitHub (pinned to 594d32ede9)