fix(workflow): 启停结果改为回读确认,不再依赖 HTTP 状态码
生产启停此前用 ok() 判定结果,该函数只读 response.status 是否等于 200: - 漏掉 HTTP 200 携带 code != 200 的业务失败,与 README「HTTP 200 不等于业务成功」冲突; - 反向也会错,服务端 204 成功会被判成失败。 本次调整: - 删除 transport/response.ts 的 ok(),消除这一判定来源; - toggleWorkflowState 改用 readEasoWriteResponse 校验 EASO 业务码; - management toggleWorkflow 写操作后回读详情确认状态,未变化抛 BusinessError (WORKFLOW_STATE_NOT_APPLIED),回读失败返回 verified: false,不谎称已生效; - lifecycle handleToggle 此前完全不看返回值,无条件输出 [SUCCESS] 且 exitCode 0, 现按 verified 给出 stderr 与退出码;handlePublish 同步调整; - 新增 WorkflowToggleResult 模型并从 services 导出; - 测试覆盖四种情形:回读确认成功、状态未生效、业务失败、回读失败。
This commit is contained in:
1 parent
eb9b979943
commit
6dc96a5eb9
7 files changed
+125
-21
No files matched your search
@@ -174,3 +174,19 @@ export type WorkflowSummary = z.infer<typeof WorkflowSummarySchema>;
|
||||
export type WorkflowListAllError = z.infer<typeof WorkflowListAllErrorSchema>;
|
||||
export type TaskMatch = z.infer<typeof TaskMatchSchema>;
|
||||
export type WorkflowWithMatches = z.infer<typeof WorkflowWithMatchesSchema>;
|
||||
|
||||
// ── 启停结果 ──────────────────────────────────────────────────────────────────
|
||||
|
||||
/**
|
||||
* 工作流启停结果。启停是生产开关,必须在写操作之后回读确认:
|
||||
* `verified` 区分「已确认生效」与「已提交但未能确认」,两者都不能谎称成功。
|
||||
* `state` 为 null 表示未能读到服务端实际状态。
|
||||
*/
|
||||
export interface WorkflowToggleResult {
|
||||
pipelineId: string;
|
||||
requestedState: WorkflowState;
|
||||
state: WorkflowState | null;
|
||||
success: boolean;
|
||||
verified: boolean;
|
||||
message: string;
|
||||
}
|
||||
Reference in new issue
Block a user