Skip to content

Commit 8bc4e93

Browse files
fix(review): skip media preprocessing for local-range
1 parent 8dd03e1 commit 8bc4e93

2 files changed

Lines changed: 85 additions & 2 deletions

File tree

‎src/clawsweeper.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16588,7 +16588,13 @@ function reviewCommand(args: Args): void {
1658816588
const contextElapsedMs = Date.now() - contextStartedAt;
1658916589
const codexWorkDir = join(artifactDir, "codex");
1659016590
const proofScratchDir = join(codexWorkDir, "proof-scratch", String(item.number));
16591-
const preparedMediaProof = prepareMediaProofArtifacts(context, proofScratchDir);
16591+
// --local-range is a pre-PR LOCAL code review — it has no telegram-visible-proof to
16592+
// capture, and prepareMediaProofArtifacts would host-side `curl` + `ffmpeg` any media URL
16593+
// in the synthetic body (commit message / --body-file). Skip it entirely for local-range:
16594+
// no host download, no transcode of body-supplied URLs.
16595+
const preparedMediaProof: PreparedMediaProof = localRangeData
16596+
? { manifestPath: null, summaryPath: null, artifacts: [] }
16597+
: prepareMediaProofArtifacts(context, proofScratchDir);
1659216598
const prompt = buildReviewPrompt(
1659316599
item,
1659416600
context,

‎test/local-range-review.test.ts‎

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import assert from "node:assert/strict";
22
import test from "node:test";
33
import { execFileSync, spawnSync } from "node:child_process";
4-
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
4+
import { chmodSync, existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
5+
import { createServer } from "node:http";
56
import { tmpdir } from "node:os";
67
import { join } from "node:path";
78
import { fileURLToPath } from "node:url";
@@ -243,3 +244,79 @@ test("review rejects --item-number combined with --local-range", () => {
243244
rmSync(dir, { recursive: true, force: true });
244245
}
245246
});
247+
248+
test("--local-range does not host-download proof video URLs from the body", async () => {
249+
const hits: string[] = [];
250+
const server = createServer((req, res) => {
251+
hits.push(req.url ?? "");
252+
res.writeHead(404);
253+
res.end();
254+
});
255+
await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve));
256+
const port = (server.address() as { port: number }).port;
257+
const dir = initRepo();
258+
const codexDir = mkdtempSync(join(tmpdir(), "lrr-codex-"));
259+
const fakeCodex = join(codexDir, "fake-codex.sh");
260+
const fakeCodexMarker = join(codexDir, "fake-codex-ran.txt");
261+
writeFileSync(fakeCodex, '#!/bin/sh\nprintf "ran\\n" > "$FAKE_CODEX_MARKER"\nexit 1\n');
262+
chmodSync(fakeCodex, 0o755);
263+
try {
264+
writeFileSync(join(dir, "a.txt"), "x\n");
265+
git(dir, "add", "a.txt");
266+
git(dir, "commit", "-q", "-m", "init");
267+
git(dir, "branch", "base-ref");
268+
writeFileSync(join(dir, "b.txt"), "y\n");
269+
git(dir, "add", "b.txt");
270+
// a video URL in the commit body that media-proof preprocessing would otherwise curl
271+
git(
272+
dir,
273+
"commit",
274+
"-q",
275+
"-m",
276+
`feat: thing\n\nproof video: http://127.0.0.1:${port}/proof.mp4`,
277+
);
278+
// codex is stubbed (CODEX_BIN exits 1) so no real engine runs; media-proof would still
279+
// curl the URL BEFORE the engine if it weren't skipped for --local-range.
280+
const result = spawnSync(
281+
"node",
282+
[
283+
CLI,
284+
"review",
285+
"--local-only",
286+
"--local-range",
287+
"--base",
288+
"base-ref",
289+
"--target-repo",
290+
"openclaw/clawsweeper",
291+
"--target-dir",
292+
dir,
293+
"--artifact-dir",
294+
join(codexDir, "artifacts"),
295+
],
296+
{
297+
encoding: "utf8",
298+
env: {
299+
...process.env,
300+
CLAWSWEEPER_CODEX_REVIEW_ATTEMPTS: "1",
301+
CODEX_BIN: fakeCodex,
302+
FAKE_CODEX_MARKER: fakeCodexMarker,
303+
},
304+
timeout: 60000,
305+
},
306+
);
307+
assert.notEqual(result.status, 0, "fake Codex should make the review fail after setup");
308+
assert.equal(readFileSync(fakeCodexMarker, "utf8"), "ran\n");
309+
assert.equal(
310+
hits.length,
311+
0,
312+
`--local-range must not host-download body video URLs (server hits: ${JSON.stringify(hits)})`,
313+
);
314+
} finally {
315+
if (existsSync(fakeCodexMarker)) rmSync(fakeCodexMarker, { force: true });
316+
await new Promise<void>((resolve, reject) =>
317+
server.close((error) => (error ? reject(error) : resolve())),
318+
);
319+
rmSync(codexDir, { recursive: true, force: true });
320+
rmSync(dir, { recursive: true, force: true });
321+
}
322+
});

0 commit comments

Comments
 (0)