mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 21:00:44 +00:00
fix: keep sandbox reply fallback narrow
This commit is contained in:
@@ -94,6 +94,34 @@ describe("createReplyMediaPathNormalizer", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("drops sandbox-mapped media when staging fails instead of retrying the workspace fallback", async () => {
|
||||
ensureSandboxWorkspaceForSession.mockResolvedValue({
|
||||
workspaceDir: "/tmp/sandboxes/session-1",
|
||||
containerWorkdir: "/workspace",
|
||||
});
|
||||
resolveOutboundAttachmentFromUrl.mockRejectedValueOnce(new Error("media too large"));
|
||||
const normalize = createReplyMediaPathNormalizer({
|
||||
cfg: {},
|
||||
sessionKey: "session-key",
|
||||
workspaceDir: "/tmp/agent-workspace",
|
||||
});
|
||||
|
||||
const result = await normalize({
|
||||
mediaUrls: ["./out/photo.png"],
|
||||
});
|
||||
|
||||
expect(result).toMatchObject({
|
||||
mediaUrl: undefined,
|
||||
mediaUrls: undefined,
|
||||
});
|
||||
expect(resolveOutboundAttachmentFromUrl).toHaveBeenCalledTimes(1);
|
||||
expect(resolveOutboundAttachmentFromUrl).toHaveBeenCalledWith(
|
||||
path.join("/tmp/sandboxes/session-1", "out", "photo.png"),
|
||||
5 * 1024 * 1024,
|
||||
expect.any(Object),
|
||||
);
|
||||
});
|
||||
|
||||
it("drops host file URLs when no sandbox mapping applies", async () => {
|
||||
const normalize = createReplyMediaPathNormalizer({
|
||||
cfg: {},
|
||||
|
||||
@@ -180,13 +180,12 @@ export function createReplyMediaPathNormalizer(params: {
|
||||
!WINDOWS_DRIVE_RE.test(media);
|
||||
const sandboxRoot = await resolveSandboxRoot();
|
||||
if (sandboxRoot) {
|
||||
let sandboxResolvedMedia: string;
|
||||
try {
|
||||
return await persistLocalReplyMedia(
|
||||
await resolveSandboxedMediaSource({
|
||||
media,
|
||||
sandboxRoot,
|
||||
}),
|
||||
);
|
||||
sandboxResolvedMedia = await resolveSandboxedMediaSource({
|
||||
media,
|
||||
sandboxRoot,
|
||||
});
|
||||
} catch (err) {
|
||||
if (!isLikelyLocalMediaSource(media)) {
|
||||
throw err;
|
||||
@@ -202,6 +201,7 @@ export function createReplyMediaPathNormalizer(params: {
|
||||
}
|
||||
return await persistLocalReplyMedia(media);
|
||||
}
|
||||
return await persistLocalReplyMedia(sandboxResolvedMedia);
|
||||
}
|
||||
if (isRelativeLocalMedia) {
|
||||
return await persistLocalReplyMedia(resolveWorkspaceRelativeMedia(media));
|
||||
|
||||
Reference in New Issue
Block a user