Skip to content

Commit 8b568f6

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

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

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

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,25 @@ 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+
if (this.config.publicAccess) {
215+
(error as Error).message =
216+
`Build not found or not accessible to the public`;
217+
}
218+
throw error;
219+
}
212220
}
213221

214222
async delete({

0 commit comments

Comments
 (0)