yikart/AiToEarn · error · AppException

InvalidAiTaskId

InvalidAiTaskId

Error message

ResponseCode.InvalidAiTaskId

What it means

callback() resolves the internal AI log by the Volcengine task id. It throws AppException(ResponseCode.InvalidAiTaskId) when no AI log exists for that task id, or when the found log's channel is not Volcengine — meaning the callback does not correspond to a known Volcengine task in this system.

Source

Thrown at project/aitoearn-backend/apps/aitoearn-ai/src/core/ai/video/volcengine/volcengine.service.ts:282

      request: normalized.aiLogRequest,
      status: AiLogStatus.Generating,
    })

    return {
      ...result,
      id: aiLog.id,
    } as CreateVideoGenerationTaskResponse
  }

  /**
   * Volcengine回调处理
   */
  async callback(callbackData: GetVideoGenerationTaskResponse) {
    const { id, status, updated_at, content } = callbackData

    const aiLog = await this.aiLogRepo.getByTaskId(id)
    if (!aiLog || aiLog.channel !== AiLogChannel.Volcengine) {
      throw new AppException(ResponseCode.InvalidAiTaskId)
    }
    const volcengineAiLog = aiLog as VolcengineVideoAiLog

    if (volcengineAiLog.status !== AiLogStatus.Generating) {
      return
    }

    if (
      status !== VolcTaskStatus.Succeeded
      && status !== VolcTaskStatus.Failed
      && status !== VolcTaskStatus.Expired
    ) {
      return
    }

    let aiLogStatus: AiLogStatus
    switch (status) {
      case VolcTaskStatus.Succeeded:

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Verify the task id in the callback matches an existing ai_logs row with channel=Volcengine
  2. Check the callback URL configuration points to the correct environment/database
  3. Confirm the log wasn't deleted before the callback arrived; re-create the task if needed

Example fix

null
Defensive patterns

Strategy: try-catch

Try / catch

try { await volcengineService.callback(callbackData) } catch (e) { if (e instanceof AppException && e.code === ResponseCode.InvalidAiTaskId) { logger.warn({ taskId: callbackData.id }, 'unknown volcengine callback'); return; } throw e }

Prevention

When it happens

Trigger: Volcengine posts a completion callback with a task id that was never created here, was deleted, or belongs to another channel; environment mismatch (callback delivered to the wrong deployment); duplicated/replayed callback after log cleanup.

Common situations: Misconfigured callback URL pointing at another environment (staging vs prod); tasks created before a DB restore; third parties probing the callback endpoint with random ids.

Related errors


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