From 401540253460ef97575b0750cfee596387a4a103 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 9 May 2026 15:38:27 +0100 Subject: [PATCH] test: tighten sandbox mounted path assertions --- ...ls.sandbox-mounted-paths.workspace-only.test.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/agents/pi-tools.sandbox-mounted-paths.workspace-only.test.ts b/src/agents/pi-tools.sandbox-mounted-paths.workspace-only.test.ts index e83013e8760..dc6251b4e21 100644 --- a/src/agents/pi-tools.sandbox-mounted-paths.workspace-only.test.ts +++ b/src/agents/pi-tools.sandbox-mounted-paths.workspace-only.test.ts @@ -103,9 +103,10 @@ describe("tools.fs.workspaceOnly", () => { await expect( writeTool?.execute("t2", { path: "/agent/owned.txt", content: "x" }), ).rejects.toThrow(/Path escapes sandbox root/i); - await expect(fs.stat(path.join(agentRoot, "owned.txt"))).rejects.toMatchObject({ - code: "ENOENT", - }); + const missingOwnedFile = await fs + .stat(path.join(agentRoot, "owned.txt")) + .catch((error: unknown) => error); + expect((missingOwnedFile as NodeJS.ErrnoException).code).toBe("ENOENT"); await expect( editTool?.execute("t3", { path: "/agent/secret.txt", oldText: "shh", newText: "nope" }), @@ -129,9 +130,10 @@ describe("tools.fs.workspaceOnly", () => { await expect(applyPatchTool.execute("t1", { input: APPLY_PATCH_PAYLOAD })).rejects.toThrow( /Path escapes sandbox root/i, ); - await expect(fs.stat(path.join(agentRoot, "pwned.txt"))).rejects.toMatchObject({ - code: "ENOENT", - }); + const missingPatchedFile = await fs + .stat(path.join(agentRoot, "pwned.txt")) + .catch((error: unknown) => error); + expect((missingPatchedFile as NodeJS.ErrnoException).code).toBe("ENOENT"); }); });