yikart/AiToEarn · warning · Error

HTTP ${response.status}

Error message

HTTP ${response.status}

What it means

publishVideo requires createVideoDto.accountId (from the CreateVideoDto body) and a separate videoId body field. If either is missing it throws BadRequestException('accountId和videoId是必须的'). The flow publishes a previously uploaded video identified by videoId under the given TikTok account.

Source

Thrown at project/aitoearn-backend/apps/aitoearn-ai/src/core/agent/mcp/volcengine/volcengine.utils.ts:90

    }
  }

  /**
   * 获取图片尺寸
   * @param imageUrl 图片 URL
   * @param logger 日志记录器
   * @returns 图片的宽度和高度
   */
  static async getImageDimensions(
    imageUrl: string,
    logger: Logger,
  ): Promise<{ width: number, height: number }> {
    try {
      logger.debug('[getImageDimensions] Fetching image dimensions', { url: imageUrl })

      const response = await fetch(imageUrl)
      if (!response.ok) {
        throw new Error(`HTTP ${response.status}`)
      }

      const arrayBuffer = await response.arrayBuffer()
      const buffer = Buffer.from(arrayBuffer)
      const dimensions = sizeOf(buffer)

      if (!dimensions.width || !dimensions.height) {
        throw new Error('Failed to get image dimensions')
      }

      logger.debug('[getImageDimensions] Image dimensions retrieved', {
        width: dimensions.width,
        height: dimensions.height,
      })

      return {
        width: dimensions.width,
        height: dimensions.height,

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Include both { accountId, ..., videoId } at the top level of the JSON body.
  2. Complete the upload step first and use the returned videoId.
  3. Ensure videoId is a body field, not nested inside createVideoDto properties the controller doesn't read.

Example fix

// before
await api.post('/plat/tiktok/publish', { accountId, title });
// after
await api.post('/plat/tiktok/publish', { accountId, title, videoId: uploadResult.videoId });
Defensive patterns

Strategy: validation

Validate before calling

if (!createVideoDto.accountId || !videoId) throw new Error('accountId和videoId是必须的');
await api.post('/plat/tiktok/publish', { ...createVideoDto, videoId });

Type guard

function canPublish(dto: unknown, videoId: unknown): dto is { accountId: string } & Record<string, unknown> {
  return typeof (dto as any)?.accountId === 'string' && (dto as any).accountId.length > 0 && typeof videoId === 'string' && videoId.length > 0;
}

Try / catch

try {
  return await api.post('/plat/tiktok/publish', { ...dto, videoId });
} catch (e) {
  if (e.response?.status === 400) console.error('发布前必须先上传并拿到videoId');
  throw e;
}

Prevention

When it happens

Trigger: POST the publish route with a body lacking accountId in the DTO object or lacking a top-level videoId field, or publishing before the upload step returned a videoId.

Common situations: Client tries to publish straight from a draft without first uploading (no videoId yet), or nests videoId inside the DTO instead of at the body top level where @Body('videoId') reads it.

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


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