{"record":{"id":"a0876c87e6cac424","repo":"yikart/AiToEarn","slug":"error","errorCode":null,"errorMessage":"任务不存在","messagePattern":"任务不存在","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"warning","filePath":"project/aitoearn-backend/apps/aitoearn-ai/src/core/ai/image/image.service.ts","lineNumber":489,"sourceCode":"      type: AiLogType.Image,\n      retry: this.getImageModelRetry(params.model, 'edit'),\n      request: { ...params, user: userId },\n      taskType: 'edit',\n    })\n\n    return {\n      logId: log.id,\n      status: AiLogStatus.Generating,\n    }\n  }\n\n  /**\n   * 查询任务状态\n   */\n  async getTaskStatus(logId: string) {\n    const log = await this.aiLogRepo.getById(logId)\n    if (!log || log.type !== AiLogType.Image) {\n      throw new NotFoundException('任务不存在')\n    }\n    const response = log.response as ImageAiLogResponse | undefined\n\n    // 提取图片信息\n    let images: AiLogImageResult[] | undefined\n    if (response?.list?.length) {\n      images = response.list\n    }\n    else if (response?.images?.length) {\n      images = response.images\n    }\n    else if (response?.image) {\n      images = [{ url: response.image }]\n    }\n    else if (response?.imageUrl) {\n      images = [{ url: response.imageUrl }]\n    }\n","sourceCodeStart":471,"sourceCodeEnd":507,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-ai/src/core/ai/image/image.service.ts#L471-L507","documentation":"getTaskStatus looks up an async image generation task by its AI log id. It throws NotFoundException('任务不存在') when no log record with that id exists, or the record exists but is not of type AiLogType.Image — i.e. the id never belonged to an image task.","triggerScenarios":"Polling getTaskStatus with an id that was never created (submit failed), a typo'd/truncated logId, passing an id from a different task type (e.g. a video or text AI log), or querying after log retention cleanup removed the record.","commonSituations":"Client polls with the wrong identifier (e.g. upstream provider task id instead of the internal logId); record pruned by data-retention; cross-service id confusion.","solutions":["Use the exact logId returned when the image task was submitted, not the provider-side task id","Verify the id belongs to an image generation task (AiLogType.Image), not another AI log type","Check the DB/aiLogRepo record exists for that id; if recently created, rule out replica lag","If records expire, re-check within the retention window or persist the id on your side"],"exampleFix":"// before\nconst status = await imageService.getTaskStatus(providerTaskId)\n// after\nconst status = await imageService.getTaskStatus(submitResult.logId) // id returned by the submit call","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isImageTaskLog(log: AiLog | undefined): log is AiLog & { type: AiLogType.Image } {\n  return !!log && log.type === AiLogType.Image\n}","tryCatchPattern":"try {\n  const status = await imageService.getTaskStatus(logId)\n} catch (e) {\n  if (e instanceof NotFoundException) {\n    return { state: 'unknown', reason: 'task id not found or not an image task' }\n  }\n  throw e\n}","preventionTips":["Store and reuse the logId returned by the submit call — never the provider-side task id","Treat 404 on polling as terminal if the record was created long ago (retention may have pruned it)","Distinguish per-task-type ids (image vs video vs text) in your own storage"],"tags":["not-found","task","validation"],"backgroundTag":"resource-not-found","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}