{"record":{"id":"9cb5e63c71689d7c","repo":"yikart/AiToEarn","slug":"statusresult-error-message","errorCode":null,"errorMessage":"视频发布失败: ${statusResult.error_message || '未知错误'}","messagePattern":"视频发布失败: (.+?)","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"project/aitoearn-electron/server/src/modules/plat/tiktok/tiktok.service.ts","lineNumber":575,"sourceCode":"        tries++;\n        \n        const statusResult = await this.checkPublishStatus(accessToken, publish_id);\n        this.logger.debug(`状态检查 ${tries}/${maxRetries}: ${JSON.stringify(statusResult)}`);\n        \n        // 判断视频是否发布成功\n        // 根据实际API返回的状态字段来判断（这里的status字段可能需要根据实际情况调整）\n        if (statusResult.status === 'SUCCESS' || statusResult.status === 'PUBLISHED') {\n          finalStatus = statusResult;\n          break;\n        } else if (statusResult.status === 'FAILED' || statusResult.status === 'ERROR') {\n          // 更新发布记录为失败状态\n          await this.pubRecordModel.findByIdAndUpdate(pubRecord._id, {\n            status: PubStatus.FAIL,\n            failReason: statusResult.error_message || '发布失败',\n            updateTime: new Date()\n          });\n          \n          throw new BadRequestException(`视频发布失败: ${statusResult.error_message || '未知错误'}`);\n        }\n        \n        // 等待指定时间后再次查询\n        await new Promise(resolve => setTimeout(resolve, pollInterval));\n      }\n      \n      if (!finalStatus) {\n        // 超时仍未完成\n        await this.pubRecordModel.findByIdAndUpdate(pubRecord._id, {\n          status: PubStatus.FAIL,\n          failReason: '检查视频发布状态超时',\n          updateTime: new Date()\n        });\n        \n        throw new BadRequestException('视频发布状态检查超时，请稍后在TikTok应用中查看发布状态');\n      }\n      \n      // 更新发布记录为成功状态","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-electron/server/src/modules/plat/tiktok/tiktok.service.ts#L557-L593","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"// Pre-upload sanity: TikTok-recommended container/codec can't be verified via API,\n// but you can gate on basic constraints before upload.\nif (!videoBuffer?.length || videoBuffer.length > 4 * 1024 * 1024 * 1024) {\n  throw new Error('video size out of TikTok-acceptable range');\n}","typeGuard":"function isFailedStatus(s: unknown): s is { status: 'FAILED' | 'ERROR'; error_message?: string; error_code?: number } {\n  const o = s as any;\n  return (o?.status === 'FAILED' || o?.status === 'ERROR');\n}","tryCatchPattern":"try {\n  await tiktokService.uploadAndPublishVideo(token, userId, accountId, buffer, info);\n} catch (e) {\n  if (e.message.startsWith('视频发布失败:')) {\n    const reason = e.message.slice('视频发布失败:'.length);\n    logger.warn(`TikTok rejected publish: ${reason}`);\n    // surface reason to user; optionally re-encode and retry with a fresh publish\n  } else throw e;\n}","preventionTips":["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."],"tags":["tiktok","publish-failed","video-processing","polling"],"backgroundTag":"remote-publish-rejected","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}