{"record":{"id":"0491bcb9db170b74","repo":"toeverything/AFFiNE","slug":"ready-or-settled-transcript-tasks-cannot-be-retrie","errorCode":null,"errorMessage":"Ready or settled transcript tasks cannot be retried","messagePattern":"Ready or settled transcript tasks cannot be retried","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"packages/backend/server/src/plugins/copilot/transcript/retry.ts","lineNumber":42,"sourceCode":"\n  constructor(\n    private readonly models: Models,\n    private readonly job: JobQueue,\n    private readonly runtime: CapabilityRuntime,\n    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,","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/b4c8548c09da21b2898443559a5b846f0ccf5dd8/packages/backend/server/src/plugins/copilot/transcript/retry.ts#L24-L60","documentation":"A BadRequestException guard in the transcript retry flow: it fires when retryTask is invoked on a task whose status is 'ready' or 'settled', i.e. transcription already completed and produced a final result. Retrying such tasks is meaningless, so the request is rejected before any job is re-enqueued; the input at fault is taskId pointing at an already-finished task.","triggerScenarios":"Thrown at packages/backend/server/src/plugins/copilot/transcript/retry.ts:42 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Only retry jobs that are in a failed state; ready or settled jobs are final.","Check the job status first and skip the retry when it already succeeded.","If the result is wrong, create a new transcription job instead of retrying a settled one."],"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"}