merge: integrate review-16-node-grant-failure

This commit is contained in:
gitea committed 2026-10-20 23:03:31 +08:00
commit 4537c6eb53
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
@@ -606,9 +606,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}] ======`,
@@ -143,3 +143,5 @@ hose-use workflow eval-script --code="return a + b;" --input='{"a":1,"b":2}'
脚本静态校验和离线仿真的本地、远端节点路径均支持 `--json/-j` 与 `--output-file`:stdout 返回 JSON 报告或导出摘要,失败时保留结构化错误并返回非零退出码。
快照 Diff 对比节点的全部配置字段(脚本和过滤器沿用专用输出),覆盖 `mapping/inputs/fields` 及自定义配置。节点顺序或父容器变化通过 `configChanges` 中的 `$path` 表达,不依赖服务端是否重算索引。
灰度开通网关明确返回失败时,CLI 保留失败详情并返回非零退出码;文本输出不再宣称权限生效,JSON 中的 `success` 与退出码保持一致。