Skip to content

Commit 2793051

Browse files
committed
improve error message for s3 public access
1 parent a829780 commit 2793051

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

packages/provider-s3/src/lib/providerS3.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,22 @@ export class S3BuildCache implements RemoteBuildCache {
198198
}: {
199199
artifactName: string;
200200
}): Promise<Response> {
201-
const res = await this.s3.send(
202-
new clientS3.GetObjectCommand({
203-
Bucket: this.bucket,
204-
Key: `${this.directory}/${artifactName}.zip`,
205-
}),
206-
);
207-
return new Response(toWebStream(res.Body as Readable), {
208-
headers: {
209-
'content-length': String(res.ContentLength),
210-
},
211-
});
201+
try {
202+
const res = await this.s3.send(
203+
new clientS3.GetObjectCommand({
204+
Bucket: this.bucket,
205+
Key: `${this.directory}/${artifactName}.zip`,
206+
}),
207+
);
208+
return new Response(toWebStream(res.Body as Readable), {
209+
headers: {
210+
'content-length': String(res.ContentLength),
211+
},
212+
});
213+
} catch (error) {
214+
(error as Error).message = `Build not found or not accessible to the public`;
215+
throw error;
216+
}
212217
}
213218

214219
async delete({

0 commit comments

Comments
 (0)