{"record":{"id":"a9d7190b66b4f9d7","repo":"yikart/AiToEarn","slug":"error-a9d719","errorCode":null,"errorMessage":"任务不存在","messagePattern":"任务不存在","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"project/aitoearn-electron/server/src/modules/task/adminUserTask.controller.ts","lineNumber":65,"sourceCode":"  @Get('count/approved/task')\n  async getCompletedTaskCount() {\n    return this.adminUserTaskService.getCompletedTaskCount();\n  }\n\n  @Get('count/approved/user')\n  async getCompletedUserCount() {\n    return this.adminUserTaskService.getCompletedUserCount();\n  }\n\n  // 通过\n  @ApiResult({ type: Boolean })\n  @Put('verify/approved/:id')\n  async verifyUserTaskApproved(\n    @GetToken() verifier: TokenInfo,\n    @Param('id') id: string,\n  ) {\n    const userTask = await this.userTaskService.getUserTaskInfoById(id);\n    if (!userTask) throw new NotFoundException('任务不存在');\n    if (userTask.status !== UserTaskStatus.PENDING)\n      throw new AppHttpException(ErrHttpBack.user_task_err_status);\n\n    return this.adminUserTaskService.verifyUserTaskApproved(userTask, {\n      verifierUserId: verifier.id,\n    });\n  }\n\n  // 拒绝\n  @ApiResult({ type: Boolean })\n  @Put('verify/rejected/:id')\n  async verifyUserTaskRejected(\n    @GetToken() verifier: TokenInfo,\n    @Param('id') id: string,\n    @Body() data: RejectedTaskDto,\n  ) {\n    const userTask = await this.userTaskService.getUserTaskInfoById(id);\n    if (!userTask) throw new NotFoundException('任务不存在');","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-electron/server/src/modules/task/adminUserTask.controller.ts#L47-L83","documentation":"NestJS 404 thrown in the admin verify-approve endpoint (PUT verify/approved/:id) when getUserTaskInfoById returns no user-task record. It means the submitted user-task id is unknown, not that the approval itself failed.","triggerScenarios":"PUT verify/approved/:id with a nonexistent/deleted user-task id or a malformed ObjectId.","commonSituations":"Auditor clicking approve after the submission was deleted or purged; stale review queue page; id of a Task passed instead of a UserTask.","solutions":["Refresh the review queue to get current user-task ids before approving.","Confirm you are using a user-task id, not a task id.","Validate id format before calling the endpoint."],"exampleFix":"// before\nif (!userTask) throw new NotFoundException('任务不存在');\n// after\nimport { isValidObjectId } from 'mongoose';\nif (!isValidObjectId(id)) throw new BadRequestException('Invalid user task id');\nconst userTask = await this.userTaskService.getUserTaskInfoById(id);\nif (!userTask) throw new NotFoundException(`User task ${id} not found`);","handlingStrategy":"validation","validationCode":"if (!/^[0-9a-f]{24}$/i.test(id)) throw new Error('Invalid user task id');\nconst ut = await api.getUserTask(id);\nif (!ut) throw new Error(`User task ${id} not found; refresh queue`);","typeGuard":null,"tryCatchPattern":"try {\n  await api.put(`/verify/approved/${id}`);\n} catch (e) {\n  if (e.response?.status === 404) {\n    await refreshAuditQueue();\n    return;\n  }\n  throw e;\n}","preventionTips":["Refresh the review queue before each approve action.","Distinguish task ids from user-task ids in the UI.","Catch 404 and reload instead of surfacing a raw error to auditors."],"tags":["rest","not-found","admin-api","task-audit"],"backgroundTag":"resource-not-found","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}