Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/src/result-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export async function exportBuildResultOutput(
): Promise<BuildResultExport> {
const manifest = await repository.read(build);
if (manifest === undefined) throw new Error(`Build Result ${build} does not exist`);
const publishedOutput = manifest.outputs[output];
const publishedOutput = Object.hasOwn(manifest.outputs, output) ? manifest.outputs[output] : undefined;
if (publishedOutput === undefined) throw new Error(`Build ${build} has no Output ${output}`);
const resolvedOutput = await repository.resolve(build, output);
if (resolvedOutput === undefined) throw new Error(`Build ${build} Output ${output} cannot be resolved`);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/result-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function browseBuildOutputHistory(
const manifest = page.results[index]!;
const sameSource = source === undefined
|| resolve(request.projectRoot, manifest.source.id) === source;
if (sameSource && manifest.outputs[request.output] !== undefined) matches.push(manifest);
if (sameSource && Object.hasOwn(manifest.outputs, request.output)) matches.push(manifest);
if (matches.length === request.limit) {
const hasOlder = index < page.results.length - 1 || page.next !== undefined;
return { results: matches, ...(hasOlder ? { next: manifest.id } : {}) };
Expand Down
11 changes: 7 additions & 4 deletions packages/result/src/node/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function applyBuildResultPresentation(
if (update.highlightedOutputs !== undefined) {
const highlighted = [...new Set(update.highlightedOutputs)];
for (const output of highlighted) {
assert(manifest.outputs[output] !== undefined,
assert(Object.hasOwn(manifest.outputs, output),
`Build Result ${manifest.id} has no Output ${output}`);
}
if (highlighted.length === 0) delete base.highlightedOutputs;
Expand Down Expand Up @@ -153,7 +153,8 @@ export async function locateRepositoryBuildResultOutput(
const manifest = await repository.read(currentBuild);
if (manifest === undefined) return undefined;
assert(manifest.outcome !== undefined, `Build ${currentBuild} is not a finished Result`);
const entry = manifest.outputs[currentOutput];
// Output names are data; `toString` must not resolve to Object.prototype.
const entry = Object.hasOwn(manifest.outputs, currentOutput) ? manifest.outputs[currentOutput] : undefined;
if (entry === undefined) return undefined;
if (entry.value.kind === "build-output") {
currentBuild = entry.value.build;
Expand Down Expand Up @@ -298,7 +299,8 @@ export async function resolveBuildResultOutput(
const directory = buildResultDirectory(root, currentBuild);
const manifest = await readBuildResult(directory);
if (manifest === undefined) return undefined;
const entry = manifest.outputs[currentOutput];
// Output names are data; `toString` must not resolve to Object.prototype.
const entry = Object.hasOwn(manifest.outputs, currentOutput) ? manifest.outputs[currentOutput] : undefined;
if (entry === undefined) return undefined;
if (entry.value.kind === "build-output") {
currentBuild = entry.value.build;
Expand Down Expand Up @@ -346,7 +348,8 @@ export async function describeBuildResultOutput(
assert(!seen.has(address), `Build Output forwarding repeats ${currentBuild} / ${currentOutput}`);
seen.add(address);
const manifest = await readBuildResult(buildResultDirectory(root, currentBuild));
const entry = manifest?.outputs[currentOutput];
const entry = manifest !== undefined && Object.hasOwn(manifest.outputs, currentOutput)
? manifest.outputs[currentOutput] : undefined;
if (entry === undefined) return undefined;
if (entry.value.kind === "build-output") {
currentBuild = entry.value.build;
Expand Down
6 changes: 6 additions & 0 deletions packages/result/test/result.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ test("one same-Build resource backs a public video and a CompositeValue payload"
repository.updatePresentation("bld_20260902T100000000Z_0000000001", { highlightedOutputs: ["missing.output"] }),
/has no Output missing\.output/u,
);
// Output names are data: names inherited from Object.prototype are not Outputs.
await assert.rejects(
repository.updatePresentation("bld_20260902T100000000Z_0000000001", { highlightedOutputs: ["constructor"] }),
/has no Output constructor/u,
);
assert.equal(await repository.resolve("bld_20260902T100000000Z_0000000001", "toString"), undefined);
const cleared = await repository.updatePresentation("bld_20260902T100000000Z_0000000001", {
outputDisplayNames: { "shot.video": null },
title: null,
Expand Down