yikart/AiToEarn · error · BadRequestException

删除视频失败: ${error.response?.data?.error?.message || error.mess

Error message

删除视频失败: ${error.response?.data?.error?.message || error.message}

What it means

The catch-all of deleteVideo (tiktok.service.ts:732-735). The POST to /v2/video/delete/ failed (HTTP error or network error), and the Axios error is converted to BadRequestException('删除视频失败: ...') with TikTok's error.message when available. Note deleteVideo returns success:true unconditionally on any 2xx, so this only fires on actual request failures.

Source

Thrown at project/aitoearn-electron/server/src/modules/plat/tiktok/tiktok.service.ts:734

    accessToken: string,
    videoId: string
  ): Promise<any> {
    try {
      const { data } = await firstValueFrom(
        this.httpService.post(`${this.apiBaseUrl}/v2/video/delete/`, {
          video_id: videoId
        }, {
          headers: {
            'Content-Type': 'application/json',
            'Authorization': `Bearer ${accessToken}`
          }
        })
      );

      return { success: true };
    } catch (error) {
      this.logger.error('删除TikTok视频失败:', error.response?.data || error.message);
      throw new BadRequestException(`删除视频失败: ${error.response?.data?.error?.message || error.message}`);
    }
  }

  /**
   * 获取视频评论列表
   * @param accessToken 访问令牌
   * @param videoId 视频ID
   * @param limit 每页结果数
   * @param cursor 分页游标
   * @returns 评论列表
   */
  async getVideoComments(
    accessToken: string,
    videoId: string,
    limit = 20,
    cursor?: string
  ): Promise<any> {
    try {

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Read the '删除TikTok视频失败:' log for error.response?.data.error (code + message + log_id).
  2. Refresh the access token if the error is 401/190 (token invalid/expired).
  3. Verify the video_id belongs to the authenticated TikTok user and still exists.
  4. Confirm the app has the required video management scope for deletion.
  5. For 5xx/network errors, retry with backoff — deletion may succeed despite the error.

Example fix

null
Defensive patterns

Strategy: retry

Validate before calling

if (!accessToken) throw new Error('missing access token');
if (!videoId) throw new Error('missing videoId');

Type guard

null

Try / catch

try {
  await tiktokService.deleteVideo(token, videoId);
} catch (e) {
  const status = (e as any).response?.status;
  if (status && status >= 500) {
    await retryWithBackoff(() => tiktokService.deleteVideo(token, videoId), 3);
  } else if (status === 401) {
    await deleteVideoWithFreshToken(videoId);
  } else throw e;
}

Prevention

When it happens

Trigger: POST /v2/video/delete/ returns 4xx/5xx — invalid/expired access token, app lacking video deletion scope, video_id not owned by the token's user, already-deleted video, or TikTok-side 5xx/network failure.

Common situations: Deleting videos of an account whose token was refreshed/revoked; using a video_id from a different TikTok user; scope not re-requested after TikTok permission changes; transient TikTok outages.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/06b1abe703f759e3. Report an issue: GitHub.