yikart/AiToEarn · error · BadRequestException
视频发布失败: ${statusResult.error_message || '未知错误'}
Error message
视频发布失败: ${statusResult.error_message || '未知错误'} What it means
Thrown by uploadAndPublishVideo (tiktok.service.ts:575) when polling /v2/post/publish/status/fetch/ returns status FAILED or ERROR. The video was uploaded, but TikTok's processing/transcoding or the actual publish rejected it. Before throwing, the local publish record is updated to PubStatus.FAIL with the TikTok error message.
Source
Thrown at project/aitoearn-electron/server/src/modules/plat/tiktok/tiktok.service.ts:575
tries++;
const statusResult = await this.checkPublishStatus(accessToken, publish_id);
this.logger.debug(`状态检查 ${tries}/${maxRetries}: ${JSON.stringify(statusResult)}`);
// 判断视频是否发布成功
// 根据实际API返回的状态字段来判断(这里的status字段可能需要根据实际情况调整)
if (statusResult.status === 'SUCCESS' || statusResult.status === 'PUBLISHED') {
finalStatus = statusResult;
break;
} else if (statusResult.status === 'FAILED' || statusResult.status === 'ERROR') {
// 更新发布记录为失败状态
await this.pubRecordModel.findByIdAndUpdate(pubRecord._id, {
status: PubStatus.FAIL,
failReason: statusResult.error_message || '发布失败',
updateTime: new Date()
});
throw new BadRequestException(`视频发布失败: ${statusResult.error_message || '未知错误'}`);
}
// 等待指定时间后再次查询
await new Promise(resolve => setTimeout(resolve, pollInterval));
}
if (!finalStatus) {
// 超时仍未完成
await this.pubRecordModel.findByIdAndUpdate(pubRecord._id, {
status: PubStatus.FAIL,
failReason: '检查视频发布状态超时',
updateTime: new Date()
});
throw new BadRequestException('视频发布状态检查超时,请稍后在TikTok应用中查看发布状态');
}
// 更新发布记录为成功状态View on GitHub (pinned to d3aa8bea5b)
Solutions
- Read statusResult.error_message and the error_code from the status response — it states TikTok's rejection reason.
- Re-encode the video to TikTok-recommended specs (H.264/AAC MP4, correct resolution and duration).
- Verify the publishing account is in good standing and not rate-limited or restricted by TikTok.
- Retry the full three-step flow with a fresh publish_id if the error code indicates a transient processing failure.
- Increase polling detail by logging the whole statusResult to capture error_code/warning fields.
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-upload sanity: TikTok-recommended container/codec can't be verified via API,
// but you can gate on basic constraints before upload.
if (!videoBuffer?.length || videoBuffer.length > 4 * 1024 * 1024 * 1024) {
throw new Error('video size out of TikTok-acceptable range');
} Type guard
function isFailedStatus(s: unknown): s is { status: 'FAILED' | 'ERROR'; error_message?: string; error_code?: number } {
const o = s as any;
return (o?.status === 'FAILED' || o?.status === 'ERROR');
} Try / catch
try {
await tiktokService.uploadAndPublishVideo(token, userId, accountId, buffer, info);
} catch (e) {
if (e.message.startsWith('视频发布失败:')) {
const reason = e.message.slice('视频发布失败:'.length);
logger.warn(`TikTok rejected publish: ${reason}`);
// surface reason to user; optionally re-encode and retry with a fresh publish
} else throw e;
} Prevention
- Transcode uploads to H.264/AAC MP4 within TikTok's resolution and duration specs.
- Avoid publishing immediately after upload — small delays reduce processing-time rejections.
- Monitor account standing; restricted accounts fail publishes non-deterministically.
- Record error_message/error_code in your own audit log for pattern analysis.
When it happens
Trigger: During the status poll loop, checkPublishStatus returns statusResult.status === 'FAILED' or 'ERROR' — TikTok rejected the video after upload (content policy violation, unsupported codec/resolution, corrupted file, account posting restrictions, or the publish transition failed server-side).
Common situations: Videos encoded in unsupported codecs (e.g. certain HEVC/VP9 profiles), videos exceeding TikTok's aspect/size constraints, shadowbanned or restricted accounts, content flagged by automated review, transient TikTok processing errors misreported as FAILED.
Related errors
- 视频发布状态检查超时,请稍后在TikTok应用中查看发布状态
- 发布视频失败: ${error.response?.data?.error?.message || error.mess
- No response from Gemini
- No subtitle entries in response
- ChannelPlatformMediaProcessingFailed
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/9cb5e63c71689d7c.
Report an issue: GitHub.