{"record":{"id":"7c911723bf71dbdb","repo":"remotion-dev/remotion","slug":"throwifsiteexists-was-passed-as-true-but-there","errorCode":null,"errorMessage":"`throwIfSiteExists` was passed as true, but there are already files in this folder: ${files.slice(0, 5).map((f) => f.Key).join(', ')}","messagePattern":"`throwIfSiteExists` was passed as true, but there are already files in this folder: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/lambda/src/shared/deploy-site-with-bundle.ts","lineNumber":107,"sourceCode":"\tconst subFolder = getSitesKey(siteName);\n\n\tconst filesPromise = providerSpecifics.listObjects({\n\t\tbucketName,\n\t\texpectedBucketOwner: accountId,\n\t\tregion,\n\t\t// The `/` is important to not accidentally delete sites with the same name but containing a suffix.\n\t\tprefix: `${subFolder}/`,\n\t\tforcePathStyle,\n\t\trequestHandler,\n\t});\n\tconst bundlePromise = getBundle();\n\tconst [files, bundleDir] = await waitForPromisesToFinish([\n\t\tfilesPromise,\n\t\tbundlePromise,\n\t] as const);\n\n\tif (throwIfSiteExists && files.length > 0) {\n\t\tthrow new Error(\n\t\t\t'`throwIfSiteExists` was passed as true, but there are already files in this folder: ' +\n\t\t\t\tfiles\n\t\t\t\t\t.slice(0, 5)\n\t\t\t\t\t.map((f) => f.Key)\n\t\t\t\t\t.join(', '),\n\t\t);\n\t}\n\n\toptions.onDiffingProgress?.(0, false);\n\n\tlet totalBytes = 0;\n\n\tconst {toDelete, toUpload, existingCount} = await getS3DiffOperations({\n\t\tobjects: files,\n\t\tbundle: bundleDir,\n\t\tprefix: subFolder,\n\t\tonProgress: (bytes) => {\n\t\t\ttotalBytes = bytes;","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda/src/shared/deploy-site-with-bundle.ts#L89-L125","documentation":"Thrown by deploySiteFromBundle() when the caller passes throwIfSiteExists: true (the default protect-against-overwrite guard) AND the S3 prefix for the given siteName already contains objects. Its purpose is to prevent silently clobbering a previously deployed site whose files live under `${subFolder}/` in the bucket.","triggerScenarios":"Re-running deploySiteFromBundle with the same siteName and the default throwIfSiteExists=true after a prior deploy. Listing the prefix via providerSpecifics.listObjects returns one or more objects.","commonSituations":"Iterating on a deploy and reusing the same siteName; CI re-running a deploy job against an existing site; deploying a second project that collides with the first site's name.","solutions":["Pick a different siteName for the new deploy so it lands in its own prefix.","Intentionally overwrite by passing throwIfSiteExists: false (or the matching options flag) once you confirm the old files are disposable.","Delete the existing site objects under the prefix first (`npx remotion lambda sites rm` / `aws s3 rm`) and re-deploy."],"exampleFix":"// before\ndeploySiteFromBundle({bucketName, region, bundleDir, siteName: 'my-video'})\n// after - opt into overwrite\ndeploySiteFromBundle({bucketName, region, bundleDir, siteName: 'my-video', options: {throwIfSiteExists: false}})","handlingStrategy":"validation","validationCode":"// Decide policy before deploy: never overwrite unless explicitly intended\nconst options = {throwIfSiteExists: process.env.OVERWRITE_SITE === '1' ? false : true}\ndeploySiteFromBundle({bucketName, region, bundleDir, siteName, options})","typeGuard":null,"tryCatchPattern":"try {\n  await deploySiteFromBundle({bucketName, region, bundleDir, siteName})\n} catch (e) {\n  if (/throwIfSiteExists/.test(e.message)) {\n    // either pick a new siteName or confirm overwrite and set throwIfSiteExists:false\n  } else throw e\n}","preventionTips":["Use a unique siteName per deploy target (e.g. include a version or commit).","Treat throwIfSiteExists:false as a destructive, opt-in action.","In CI, clean or namespace site names per branch."],"tags":["aws","s3","deployment","configuration","data-safety"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}