fix(workflow): propagate rejected node grants to CLI failure status

This commit is contained in:
gitea committed 2026-10-20 18:04:48 +08:00
1 parent fac81b08e8
commit 3141cc3b29
4 files changed
+24 -2

No files matched your search

@@ -0,0 +1,16 @@
import { expect, spyOn, test } from "bun:test";
import { handleWorkflowCommand } from "./workflow/index.js";
import { parseArgs } from "../parser.js";
import * as services from "../../domains/platform/services.js";
test("failed grants retain gateway details and never report success", async () => {
const grant = spyOn(services, "grantWorkflowNodes").mockResolvedValue({ success: false, saved: [], skipped: [], rawMessage: "permission denied" });
try {
for (const jsonMode of [false, true]) {
const result = await handleWorkflowCommand(parseArgs(["workflow", "nodes", "grant", "code-js2", "--yes"]), { selectedCorp: { id: "corp", name: "test" }, jsonMode } as any);
expect(result.exitCode).toBe(1);
expect(result.stdout).not.toContain("节点权限已生效");
if (jsonMode) expect(JSON.parse(result.stdout)).toMatchObject({ success: false, rawMessage: "permission denied" });
else expect(result.stderr).toContain("permission denied");
}
} finally { grant.mockRestore(); }
});
+4 -1
View File
@@ -598,9 +598,12 @@ async function handleGrantNodes(
return {
stdout: printJson(result, runtime.outputOptions),
stderr: "",
exitCode: 0,
exitCode: result.success ? 0 : 1,
};
}
if (!result.success) {
return { stdout: "", stderr: `灰度节点开通失败: ${result.rawMessage || "网关拒绝了开通请求"}\n`, exitCode: 1 };
}
const lines = [
`====== 灰度节点开通结果 [${corp.name}] ======`,
@@ -128,3 +128,5 @@ hose-use workflow eval-script --code="return a + b;" --input='{"a":1,"b":2}'
- 借助 Kimi 网桥(`kimi-webbridge`)建立真实微前端会话,自动探测并解析不同应用类型下的非费用类表单元数据;
- 提取出动态列、关联实体 ID 与系统字段字典,在 CLI 层面提供对非费用类业务对象的只读探针与结构化校验能力。
灰度开通网关明确返回失败时,CLI 保留失败详情并返回非零退出码;文本输出不再宣称权限生效,JSON 中的 `success` 与退出码保持一致。