refactor(workflow): throw non-retryable ApplicationFailure for validation errors

This commit is contained in:
yiling
2026-05-28 09:57:30 +08:00
parent 11d2e89a48
commit 3b08ade55d
7 changed files with 161 additions and 24 deletions
+4 -1
View File
@@ -1,3 +1,4 @@
import { ApplicationFailure } from '@temporalio/workflow'
import type { WorkflowTask } from '@/generated/prisma/client'
import { getActivities, executeActivity, TaskQueueDb, TaskQueueAgent } from '../workflow-utils'
@@ -32,7 +33,9 @@ export async function agentEmbeddingMedia(task: WorkflowTask): Promise<void> {
})
placeholderCommentId = placeholder.id
if (!task.teamId) throw new Error('Task has no teamId')
if (!task.teamId) {
throw ApplicationFailure.create({ message: 'Task has no teamId', nonRetryable: true })
}
// 1. Fetch Agent Context (Database Activity on db_queue)
const context = await executeActivity(TaskQueueDb, getEmbeddingContextActivity, {