From 0db3e59f75051fb45334d699bf12d6a60c3bb084 Mon Sep 17 00:00:00 2001 From: yu <191972707@qq.com> Date: Thu, 5 Nov 2026 13:40:29 +0800 Subject: [PATCH] fix: File_DecompressFile misleading "ADM-ZIP: Invalid filename" for missing archive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit adm-zip throws "ADM-ZIP: Invalid filename" both for corrupt entries AND when the archive file simply does not exist, which sent us chasing phantom filename issues. Now the handler checks file existence first and reports "压缩包不存在:" with a recommendation pointing out that File_CompressFile appends .zip to the full source name (a.txt -> a.txt.zip) and that the compress node's output variable should be used to chain the real artifact path. --- packages/rpa-core/src/capabilities/files.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/rpa-core/src/capabilities/files.ts b/packages/rpa-core/src/capabilities/files.ts index aeb7f94..f594bd2 100644 --- a/packages/rpa-core/src/capabilities/files.ts +++ b/packages/rpa-core/src/capabilities/files.ts @@ -246,6 +246,10 @@ register("File_CompressFile", async (_ctx, node, args) => { register("File_DecompressFile", async (_ctx, node, args) => { const source = requirePath(pick(args, ["folder_path", "path", "zip_path"]), "压缩包路径", node.id, node.componentId); + // adm-zip 对不存在的文件抛 "ADM-ZIP: Invalid filename",极具误导性;先显式检查文件存在性 + await fs.access(source).catch(() => { + throw new RuntimeError("file_not_found", `压缩包不存在:${source}`, { nodeId: node.id, componentId: node.componentId, recommendation: "确认压缩包实际产物路径(压缩组件默认在原文件名后追加 .zip,如 a.txt 会压成 a.txt.zip),或用压缩节点的输出变量传入" }); + }); const saveToSourceDir = String(args.direct_type ?? "1") !== "0"; const target = saveToSourceDir ? path.dirname(source)