pot-app/pot-desktop · error · Error
Get file_id Error: ${JSON.stringify(result)}
Error message
Get file_id Error: ${JSON.stringify(result)} What it means
createFile posts to openFile/create to reserve a file and expects the response to contain file_id, upload_id and part_info_list[0].upload_url. When res.ok is true but result['file_id'] is missing, it throws this error with the raw JSON. This means the API returned a non-error response that did not match the expected create-response schema (e.g. an exist:true dedup response without part_info_list, or a partial body).
Source
Thrown at src/window/Config/pages/Backup/utils/aliyun.jsx:265
Authorization: `Bearer ${token}`,
},
body: Body.json({
drive_id,
parent_file_id: dir_id,
name: name,
type: 'file',
check_name_mode: 'refuse',
}),
});
if (res.ok) {
const result = res.data;
if (result['file_id']) {
const file_id = result['file_id'];
const upload_id = result['upload_id'];
const upload_url = result['part_info_list'][0]['upload_url'];
return { file_id, upload_id, upload_url };
} else {
throw new Error(`Get file_id Error: ${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)}`);
}
}
}
async function getFileByPath(token, drive_id, name) {
const res = await fetch('https://openapi.alipan.com/adrive/v1.0/openFile/get_by_path', {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
},
body: Body.json({View on GitHub (pinned to 594d32ede9)
Solutions
- Log JSON.stringify(result) to see the actual body; check for exist/rapid_upload fields and handle the already-exists case
- Handle result['exist'] === true by fetching the existing file's file_id (getFileByPath) instead of treating it as an error
- Ensure part_info_list handling is guarded: access upload_url only after confirming file_id exists
- Pin/verify the API docs version for openFile/create; update response parsing to the current schema
Example fix
// before
if (result['file_id']) { ... } else {
throw new Error(`Get file_id Error: ${JSON.stringify(result)}`);
}
// after
if (result['exist'] && result['file_id']) {
return { file_id: result['file_id'], upload_id: null, upload_url: null, exist: true };
}
if (result['file_id']) { ... }
throw new Error(`createFile: unexpected response ${JSON.stringify(result)}`); Defensive patterns
Strategy: type-guard
Validate before calling
// before relying on createFile's result
const created = await createFile(token, drive_id, dir_id, name); // may throw
if (!created || typeof created.file_id !== 'string' || !created.upload_url) {
throw new Error(`createFile returned incomplete upload info: ${JSON.stringify(created)}`);
} Type guard
function isCreateFileResult(r) {
return r != null && typeof r === 'object'
&& typeof r.file_id === 'string' && r.file_id.length > 0
&& (r.upload_url == null || typeof r.upload_url === 'string');
} Try / catch
try {
const { file_id, upload_id, upload_url } = await createFile(token, drive_id, dir_id, name);
} catch (e) {
const m = String(e.message);
if (m.startsWith('Get file_id Error')) {
// inspect embedded JSON for exist/duplicate handling
const body = safeParse(m.slice('Get file_id Error: '.length));
if (body && body.exist && body.file_id) return { file_id: body.file_id, exist: true };
}
throw e;
} Prevention
- Handle the already-exists / rapid-upload response shape explicitly instead of assuming a fresh-create body
- Keep API response parsing in sync with the current alipan openAPI docs for openFile/create
- Guard part_info_list[0] access — empty part_info_list on existing files will throw separately
- Log the raw body before throwing so schema drift is immediately visible
When it happens
Trigger: The openFile/create call returns 200 but without file_id — notably when the file already exists (response contains exist:true and file_id under a different field or rapid_upload succeeded but code assumes new file); response body schema drift; check_name_mode/parent_file_id errors surfaced without a proper file_id.
Common situations: Uploading a file that already exists in the target dir so the API returns an 'exist' payload; API version change altering the create response; passing name with illegal characters so the API returns a body lacking file_id.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- Get QrCode Error: ${JSON.stringify(result)}
- Can not find status: ${JSON.stringify(result)}
- Get Status Error: ${JSON.stringify(result)}
- Can not find avatar or name: ${JSON.stringify(result)}
- Get UserInfo Error: ${JSON.stringify(result)}
AI-assisted analysis of pot-app/pot-desktop@594d32ede9 (2026-09-02).
Data as JSON: /api/errors/5268e1bb3e806b56.
Report an issue: GitHub.