jackwener/OpenCLI · error · CommandExecutionError
提交抖音上传响应缺少 video id
Error message
提交抖音上传响应缺少 video id: ${JSON.stringify(payload).slice(0, 500)} What it means
Thrown by commitVideoUploadInner when the CommitUploadInner response is HTTP-ok with no error, but no video id can be extracted from Result.Results[0] (Vid/VideoId/VideoID/vid) or uploadInfo.video_id. It means the commit succeeded per the API but the library cannot determine the resulting video id. Thrown to prevent downstream code from publishing an undefined video id.
Solutions
- Log the truncated payload from the error message and check which field actually carries the video id
- Add the new field name to the fallback chain at vod-upload.js:200
- Ensure uploadInfo.video_id is set from the earlier ApplyUploadInner response
- Re-run upload/commit; if persistent, pin to a known-good API Version param
Example fix
// before
const videoId = result.Vid ?? result.VideoId ?? result.VideoID ?? result.vid ?? uploadInfo.video_id;
// after
const videoId = result.Vid ?? result.VideoId ?? result.VideoID ?? result.vid ?? result.VideoMeta?.Vid ?? uploadInfo?.video_id;
if (!videoId) throw new Error('video id still missing: ' + JSON.stringify(result)); Defensive patterns
Strategy: type-guard
Validate before calling
if (!uploadInfo?.video_id) throw new Error('uploadInfo.video_id missing from ApplyUpload step'); Type guard
function extractVideoId(result, uploadInfo) {
const id = result?.Vid ?? result?.VideoId ?? result?.VideoID ?? result?.vid ?? uploadInfo?.video_id;
return typeof id === 'string' && id.length > 0 ? id : null;
} Try / catch
try {
const out = await commitVideoUploadInner(info, creds);
} catch (e) {
if (/缺少 video id/.test(e.message)) {
// persist raw payload and inspect field naming drift
} else throw e;
} Prevention
- Always set uploadInfo.video_id from ApplyUploadInner output before committing
- Pin/test against the current VOD API Version and watch for response-shape changelogs
- Persist raw responses during integration so shape drift is debuggable
- Fail fast in CI when video id extraction returns null
When it happens
Trigger: Douyin changes the commit response shape so none of Vid/VideoId/VideoID/vid are present; a malformed but 200-status payload; passing an uploadInfo object whose video_id was also missing; a space where media processing returns results asynchronously with empty Results.
Common situations: Douyin API version drift after a backend update; testing against a new/empty VOD space returning unexpected result wrappers; manually constructed uploadInfo objects missing video_id.
Related errors
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a0806ce4d64d41b0.
Report an issue: GitHub.
Appendix: source
Thrown at clis/douyin/_shared/vod-upload.js:202
body,
headers: { 'content-type': 'application/json;charset=UTF-8' },
});
const res = await fetch(url, { method: 'POST', headers, body, signal: AbortSignal.timeout(30000) });
const text = await res.text();
let payload;
try {
payload = JSON.parse(text);
} catch {
throw new CommandExecutionError(`提交抖音上传失败,非 JSON 响应: HTTP ${res.status} ${text.slice(0, 300)}`);
}
const error = payload?.ResponseMetadata?.Error;
if (!res.ok || error) {
throw new CommandExecutionError(`提交抖音上传失败: HTTP ${res.status} ${JSON.stringify(error ?? payload)}`);
}
const result = payload?.Result?.Results?.[0] ?? payload?.Result ?? {};
const videoId = result.Vid ?? result.VideoId ?? result.VideoID ?? result.vid ?? uploadInfo.video_id;
if (!videoId) {
throw new CommandExecutionError(`提交抖音上传响应缺少 video id: ${JSON.stringify(payload).slice(0, 500)}`);
}
const meta = result.Meta ?? result.VideoMeta ?? {};
return {
video_id: videoId,
poster_uri: result.PosterUri ?? result.PosterURI ?? result.SnapshotUri ?? result.SnapshotURI ?? '',
width: Number(meta.Width ?? meta.width ?? 720) || 720,
height: Number(meta.Height ?? meta.height ?? 1280) || 1280,
raw: result,
};
}
View on GitHub (pinned to 49907e53dc)