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}] ======`,