{"record":{"id":"e7b6ca99172eabe4","repo":"remotion-dev/remotion","slug":"a-file-was-found-in-the-bucket-bucketname-wit","errorCode":null,"errorMessage":"A file was found in the bucket \"${bucketName}\" with the key ${file.Key} which is an unexpected folder structure. Delete this file.","messagePattern":"A file was found in the bucket \"(.+?)\" with the key (.+?) which is an unexpected folder structure\\. Delete this file\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"packages/lambda-client/src/get-sites.ts","lineNumber":85,"sourceCode":"\n\tconst sites: {[key: string]: Site} = {};\n\n\tfor (const bucket of remotionBuckets) {\n\t\tconst ls = await providerSpecifics.listObjects({\n\t\t\tbucketName: bucket.name,\n\t\t\tprefix: getSitesKey(''),\n\t\t\tregion,\n\t\t\texpectedBucketOwner: accountId,\n\t\t\tforcePathStyle,\n\t\t\trequestHandler,\n\t\t});\n\n\t\tfor (const file of ls) {\n\t\t\tconst siteKeyMatch = file.Key?.match(\n\t\t\t\t/sites\\/([0-9a-zA-Z-!_.*'()]+)\\/(.*)$/,\n\t\t\t);\n\t\t\tif (!siteKeyMatch) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`A file was found in the bucket \"${bucket.name}\" with the key ${file.Key} which is an unexpected folder structure. Delete this file.`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst [, siteId] = siteKeyMatch;\n\t\t\tif (!sites[siteId]) {\n\t\t\t\tsites[siteId] = {\n\t\t\t\t\tsizeInBytes: 0,\n\t\t\t\t\tbucketName: bucket.name,\n\t\t\t\t\tlastModified: null,\n\t\t\t\t\tid: siteId,\n\t\t\t\t\tserveUrl: makeS3ServeUrl({\n\t\t\t\t\t\tbucketName: bucket.name,\n\t\t\t\t\t\tregion,\n\t\t\t\t\t\tsubFolder: getSitesKey(siteId),\n\t\t\t\t\t}),\n\t\t\t\t\tversion: null,\n\t\t\t\t};","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/lambda-client/src/get-sites.ts#L67-L103","documentation":"getSites lists objects under the sites/ prefix and expects each key to match sites/<siteId>/<rest>. If a key does not match that regex, this error is thrown, naming the offending bucket and key. It indicates bucket pollution — a file living under sites/ that is not part of a valid site.","triggerScenarios":"Calling getSites when the sites/ prefix contains a key not under a siteId subfolder (e.g. a stray file at sites/stray.json).","commonSituations":"Manual uploads to the Remotion bucket, another application sharing the bucket, corrupted/orphan keys from interrupted deploys.","solutions":["Delete the offending key named in the error (AWS console or aws s3 rm)","Keep the Remotion sites bucket dedicated to Remotion; do not store unrelated files in sites/","Use a separate bucket per project to avoid cross-tool key collisions"],"exampleFix":"# remove the stray key reported in the error\naws s3 rm s3://<bucketName>/<file.Key>","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await getSites({ region });\n} catch (err) {\n  if ((err as Error).message.includes('unexpected folder structure')) {\n    // parse the bucket/key from the message and delete the stray object, then retry\n  }\n  throw err;\n}","preventionTips":["Dedicate the Remotion bucket to Remotion only","Never manually upload files into the sites/ prefix","Run getSites periodically to catch pollution early"],"tags":["aws","s3","sites","data-integrity"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}