fix(monitor): 修复取件死信无法重排与列表 NULL 标志导致的 500
- platform/postgres: listTestPublicationsSQL 的 can_start/can_retry 在 LEFT JOIN
内容对象为空时算出 NULL,Go 侧 bool 扫描失败使整个列表接口 500,前端三个 lane
全空(表现为“待入库 0 / 全部任务 0”)。改为 COALESCE(..., false)。
- 新增 POST /api/v1/job-failures/{id}/requeue:取件任务的幂等键绑在版本上,
失败那次已占住它,重新标注同一文件不会再入队;现在按新轮次 (…:r<n>) 重排、
复位意图取件状态并把死信标记为 requeued(幂等信封 + 审计字段)。
- web: 死信区对 artifact.fetch 显示「重新入队」;系统设置新增「知识库绑定」分区,
挂上一直没被渲染的 RoutingBindingsSection,导入目标库可在页面上切换。
- 测试:真实 PostgreSQL 集成测试(NULL 折叠 + 重排轮次/幂等/拒绝)、前端死信按钮
与设置分区渲染测试。
This commit is contained in:
@@ -208,3 +208,30 @@ export async function fetchJobFailures(signal?: AbortSignal): Promise<JobFailure
|
||||
if (!isRecord(value) || !isRecord(value.data) || !Array.isArray(value.data.items)) throw new Error('失败队列响应无效')
|
||||
return value.data.items as JobFailure[]
|
||||
}
|
||||
|
||||
export interface RequeuedArtifactFetch { failure_id: string; job_id: string; version_id: string; round: number; doc_name?: string; already_queued: boolean }
|
||||
|
||||
// 源头取件死信重排:取件任务的幂等键绑在版本上,失败那次已占住它,所以重新标注
|
||||
// 同一文件不会再入队;这里让后端按新轮次重新排队(新键),并复位意图状态。
|
||||
export async function requeueJobFailure(failureId: string, reason: string): Promise<RequeuedArtifactFetch> {
|
||||
const response = await fetch(`/api/v1/job-failures/${encodeURIComponent(failureId)}/requeue`, {
|
||||
method: 'POST',
|
||||
headers: { Accept: 'application/json', 'Content-Type': 'application/json', 'Idempotency-Key': newOperationID() },
|
||||
body: JSON.stringify({ reason }),
|
||||
})
|
||||
if (!response.ok) {
|
||||
const body = (await response.json().catch(() => null)) as { error?: string } | null
|
||||
throw new Error(body?.error ?? `重新取件失败(HTTP ${response.status})`)
|
||||
}
|
||||
const value = await response.json() as unknown
|
||||
if (!isRecord(value) || !isRecord(value.data)) throw new Error('重新取件响应无效')
|
||||
const data = value.data as Record<string, unknown>
|
||||
return {
|
||||
failure_id: typeof data.failure_id === 'string' ? data.failure_id : '',
|
||||
job_id: typeof data.job_id === 'string' ? data.job_id : '',
|
||||
version_id: typeof data.version_id === 'string' ? data.version_id : '',
|
||||
round: isCount(data.round) ? data.round : 0,
|
||||
doc_name: typeof data.doc_name === 'string' ? data.doc_name : undefined,
|
||||
already_queued: data.already_queued === true,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user