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 deleteComment (tiktok.service.ts:838-841). The POST to /v2/comment/delete/ failed and is re-wrapped as BadRequestException('删除评论失败: ...') with TikTok's error message when available. Deleting a comment requires it to belong to the token's user (as author or video owner) and the comment management scope.
Source
Thrown at project/aitoearn-electron/server/src/modules/plat/tiktok/tiktok.service.ts:840
commentId: string
): Promise<any> {
try {
const { data } = await firstValueFrom(
this.httpService.post(`${this.apiBaseUrl}/v2/comment/delete/`, {
video_id: videoId,
comment_id: commentId
}, {
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 userId 用户ID
* @param accountId TikTok账号ID
* @param videoId 视频ID
* @returns 点赞结果
*/
async likeVideo(
accessToken: string,
userId: string,
accountId: string,
videoId: string
): Promise<any> {
try {View on GitHub (pinned to d3aa8bea5b)
Solutions
- Check the '删除TikTok评论失败:' log for TikTok's error code distinguishing not-found from permission errors.
- Treat 'comment not found' as already-deleted success to make deletion idempotent.
- Verify the app user authored the comment (or owns the video) — other comments cannot be deleted.
- Refresh the access token if the error is auth-related and confirm comment scopes are retained.
- Retry with backoff only for 5xx/network errors, not for 4xx permission errors.
Example fix
// before
throw new BadRequestException(`删除评论失败: ${...}`);
// after
const code = error.response?.data?.error?.code;
if (code === 'comment_not_found' || code === 'invalid_comment_id') {
return { success: true, alreadyDeleted: true };
}
throw new BadRequestException(`删除评论失败: ${...}`); Defensive patterns
Strategy: try-catch
Validate before calling
if (!videoId || !commentId) throw new Error('videoId and commentId are required'); Type guard
null
Try / catch
try {
await tiktokService.deleteComment(token, videoId, commentId);
} catch (e) {
if (/not (found|exist)|already.*deleted|invalid_comment/i.test(e.message)) {
return; // treat as already deleted
} else if ((e as any).response?.status === 403) {
// comment not owned by user — surface 'cannot delete others' comments'
} else throw e;
} Prevention
- Make delete flows idempotent — comments are often deleted twice in UI retry loops.
- Only attempt deletion of comments authored by the app user or on their videos.
- Purge cached comment_ids after successful deletion.
- Confirm comment scopes survive token refreshes.
When it happens
Trigger: POST /v2/comment/delete/ returns 4xx/5xx: comment_id already deleted or not owned by the user, missing comment scope, video_id/comment_id mismatch, invalid or expired token, or network/5xx failure.
Common situations: Retrying deletion of an already-deleted comment; deleting a comment on someone else's video that the app user didn't author; stale comment_ids cached locally after the comment was removed; token refresh losing scopes.
Related errors
- 删除视频失败: ${error.response?.data?.error?.message || error.mess
- 获取评论失败: ${error.response?.data?.error?.message || error.mess
- 发表评论失败: ${error.response?.data?.error?.message || error.mess
- 初始化视频上传失败: ${error.response?.data?.error?.message || error.m
- 视频上传发布失败: ${error.response?.data?.error?.message || error.me
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/3913bfdd83363887.
Report an issue: GitHub.