fix(artifacts): keep cancellation and the caller path in extraction refusals
Two follow-ups to #1161 from its post-merge review: - The new format preflight ran before scanArtifactInventory, which was the first cancellation check. An already-cancelled extraction of a DMG or PKG therefore reported unsupported_target instead of cancellation. Check the signal before the preflight. - The unsupported-format and encrypted-entry refusals reported the realpath. When the caller selected the target through a symlink, junction, or other alias, the diagnostic named a different path. Report the caller's input path; I/O still uses the canonical path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
b34bdcdb28
commit
eacf8461da
@@ -1,4 +1,11 @@
|
||||
import { access, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
||||
import {
|
||||
access,
|
||||
mkdir,
|
||||
readFile,
|
||||
readdir,
|
||||
symlink,
|
||||
writeFile,
|
||||
} from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
@@ -137,21 +144,33 @@ describe("artifact extraction", () => {
|
||||
const root = await createTestTempDirectory("rea-extract-dmg-");
|
||||
const image = join(root, "Image.dmg");
|
||||
await writeFile(image, "not mounted");
|
||||
// A caller-specific alias must be the path the refusal reports.
|
||||
const alias = join(root, "Alias.dmg");
|
||||
await symlink(image, alias);
|
||||
const output = join(root, "output");
|
||||
const result = await new ArtifactProvider()
|
||||
.createClient(target(image, "dmg"))
|
||||
.execute(
|
||||
"extract_artifact",
|
||||
artifactExtractionExecutionSchema.parse({ output_root: output }),
|
||||
);
|
||||
expect(result).toMatchObject({
|
||||
const extract = (signal?: AbortSignal) =>
|
||||
new ArtifactProvider()
|
||||
.createClient(target(alias, "dmg"))
|
||||
.execute(
|
||||
"extract_artifact",
|
||||
artifactExtractionExecutionSchema.parse({ output_root: output }),
|
||||
signal === undefined ? undefined : { signal },
|
||||
);
|
||||
expect(await extract()).toMatchObject({
|
||||
ok: false,
|
||||
error: {
|
||||
_tag: "AnalysisUnsupportedTargetError",
|
||||
operation: "extract_artifact",
|
||||
path: alias,
|
||||
reason: "Artifact format has no extraction reader: dmg",
|
||||
},
|
||||
});
|
||||
const controller = new AbortController();
|
||||
controller.abort();
|
||||
expect(await extract(controller.signal)).toMatchObject({
|
||||
ok: false,
|
||||
error: { _tag: "ArtifactOperationError", reason: "cancelled" },
|
||||
});
|
||||
await expect(access(output)).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user