yikart/AiToEarn · error · BadRequestException
accountId, videoId和commentId是必须的
Error message
accountId, videoId和commentId是必须的
What it means
The TikTok deleteComment endpoint returns 400 BadRequestException when accountId, videoId, or commentId is missing, empty, or falsy in the request body. The library requires all three identifiers to resolve the account's access token and target the exact comment to delete on TikTok. It is a client-input guard thrown before any TikTok API call.
Source
Thrown at project/aitoearn-electron/server/src/modules/plat/tiktok/tiktok.controller.ts:331
@ApiBody({
schema: {
type: 'object',
properties: {
accountId: { type: 'string', description: 'TikTok账号ID' },
videoId: { type: 'string', description: '视频ID' },
commentId: { type: 'string', description: '评论ID' }
},
required: ['accountId', 'videoId', 'commentId']
}
})
async deleteComment(
@GetToken() systemToken: TokenInfo,
@Body('accountId') accountId: string,
@Body('videoId') videoId: string,
@Body('commentId') commentId: string
) {
if (!accountId || !videoId || !commentId) {
throw new BadRequestException('accountId, videoId和commentId是必须的');
}
const accessToken = await this.tikTokAuthService.getUserAccessToken(accountId);
return this.tikTokService.deleteComment(accessToken, videoId, commentId);
}
/**
* 视频点赞或取消点赞
*/
@Post('videos/rate')
@ApiOperation({ summary: '视频点赞或取消点赞' })
@ApiBody({
schema: {
type: 'object',
properties: {
accountId: { type: 'string', description: 'TikTok账号ID' },
videoId: { type: 'string', description: '视频ID' },
rating: { type: 'string', description: '操作类型: like 或 unlike' }View on GitHub (pinned to d3aa8bea5b)
Solutions
- Ensure the request body includes non-empty accountId, videoId, and commentId strings.
- Fix the caller that constructs the body so it forwards commentId from the comment object being deleted.
- Update outdated client code that calls this endpoint with the old (videoId, accountId-only) shape.
Example fix
// before
await api.post('/tiktok/comment/delete', { accountId, videoId });
// after
await api.post('/tiktok/comment/delete', { accountId, videoId, commentId }); Defensive patterns
Strategy: validation
Validate before calling
const ok = [accountId, videoId, commentId].every(v => typeof v === 'string' && v.length > 0);
if (!ok) throw new Error('accountId, videoId and commentId are required'); Type guard
function hasRequired(v: unknown): v is { accountId: string; videoId: string; commentId: string } {
const o = v as Record<string, unknown>;
return typeof o.accountId === 'string' && o.accountId !== '' &&
typeof o.videoId === 'string' && o.videoId !== '' &&
typeof o.commentId === 'string' && o.commentId !== '';
} Try / catch
try {
await api.post('/tiktok/comment/delete', { accountId, videoId, commentId });
} catch (e) {
if (e.response?.status === 400) {
console.error('Missing required fields:', e.response.data?.message);
}
} Prevention
- Centralize a body-builder for TikTok comment operations that asserts required IDs.
- Type the request payloads so TypeScript enforces commentId presence.
- Log the outgoing body (redacted) when a 400 occurs to spot missing fields quickly.
When it happens
Trigger: POSTing to deleteComment with a body missing one of accountId, videoId, commentId, or sending empty-string values for any of them.
Common situations: Frontend forms not collecting commentId; partial serialization of the comment object; stale clients built before commentId was added to the API contract.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- videoId, userId和accountId是必须的
- accountId和视频大小是必须的
- accountId和publishId是必须的
- No subtitle entries in response
- userId是必需的
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/a74721b51c665163.
Report an issue: GitHub.