Check for 0 sized artifact lists

This commit is contained in:
Daniel Kennedy
2026-02-24 12:21:35 -05:00
parent d584ea9caa
commit 7396e85e4a
2 changed files with 15 additions and 0 deletions
@@ -373,6 +373,17 @@ describe('upload-artifact', () => {
})
describe('skipArchive option', () => {
it('should throw an error if skipArchive is true and files array is empty', async () => {
const uploadResp = uploadArtifact(
fixtures.inputs.artifactName,
[],
fixtures.inputs.rootDirectory,
{skipArchive: true}
)
await expect(uploadResp).rejects.toThrow(FilesNotFoundError)
})
it('should throw an error if skipArchive is true and multiple files are provided', async () => {
const uploadResp = uploadArtifact(
fixtures.inputs.artifactName,
@@ -32,6 +32,10 @@ export async function uploadArtifact(
): Promise<UploadArtifactResponse> {
let artifactFileName = `${name}.zip`
if (options?.skipArchive) {
if (files.length === 0) {
throw new FilesNotFoundError([])
}
if (files.length > 1) {
throw new Error(
'skipArchive option is only supported when uploading a single file'