{"record":{"id":"61d06591fc453828","repo":"toeverything/AFFiNE","slug":"only-failed-transcript-tasks-can-be-retried","errorCode":null,"errorMessage":"Only failed transcript tasks can be retried","messagePattern":"Only failed transcript tasks can be retried","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"packages/backend/server/src/plugins/copilot/transcript/retry.ts","lineNumber":47,"sourceCode":"    private readonly realtime: RealtimePublisher\n  ) {}\n\n  async retryTask(userId: string, workspaceId: string, taskId: string) {\n    const task = await this.models.copilotTranscriptTask.getWithUser(\n      userId,\n      workspaceId,\n      taskId\n    );\n    if (!task) {\n      throw new CopilotTranscriptionJobNotFound();\n    }\n    if (task.status === 'ready' || task.status === 'settled') {\n      throw new BadRequestException(\n        'Ready or settled transcript tasks cannot be retried'\n      );\n    }\n    if (task.status !== 'failed') {\n      throw new BadRequestException(\n        'Only failed transcript tasks can be retried'\n      );\n    }\n\n    const payload = TranscriptPayloadSchema.parse(task.protectedResult);\n    await this.runtime.assertRoute(\n      'transcript.audio',\n      {},\n      {\n        user: userId,\n        workspace: workspaceId,\n        featureKind: 'transcript',\n        builtInRouteId: TRANSCRIPT_PROMPT_REF,\n      }\n    );\n    const generation = randomUUID();\n    const retryOf = task.actionRunId ?? null;\n    const claimed = await this.models.copilotTranscriptTask.claimRetry(","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/backend/server/src/plugins/copilot/transcript/retry.ts#L29-L65","documentation":"A status-machine guard in transcript retry: after ruling out 'ready'/'settled' tasks, this fires when the task status is anything other than 'failed' (e.g. 'pending' or 'running'). Only failed transcription tasks may be re-enqueued, so the retry request for taskId is rejected as a bad request rather than corrupting an in-flight task.","triggerScenarios":"Thrown at packages/backend/server/src/plugins/copilot/transcript/retry.ts:47 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the job status and only call retry on jobs whose status is failed.","Wait for the job to finish; a running or completed job cannot be retried.","Create a new transcription job if the current one is not retryable."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b4c8548c09da21b2898443559a5b846f0ccf5dd8","analyzedAt":"2026-08-18T21:16:52.546Z","contentChangedAt":"2026-08-18T21:16:52.546Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}