{"record":{"id":"1e91ae8cd4e4b17d","repo":"HeyPuter/puter","slug":"conflict-1e91ae","errorCode":"conflict","errorMessage":"Duplicate file content for batch index ${itemIndex}","messagePattern":"Duplicate file content for batch index (.+?)","errorType":"exception","errorClass":"HttpError","httpStatus":409,"severity":"warning","filePath":"src/backend/controllers/fs/FSController.ts","lineNumber":683,"sourceCode":"                                400,\n                                'Batch write manifest is missing',\n                                { legacyCode: 'bad_request' },\n                            );\n                        }\n\n                        const itemIndex = this.#resolveMultipartFileIndex(\n                            fieldName,\n                            currentFileOrder,\n                            parsedManifest,\n                        );\n                        if (parsedManifest.ignoredItemIndexes.has(itemIndex)) {\n                            if (!stream.readableEnded && !stream.destroyed) {\n                                stream.resume();\n                            }\n                            return null;\n                        }\n                        if (uploadedIndexes.has(itemIndex)) {\n                            throw new HttpError(\n                                409,\n                                `Duplicate file content for batch index ${itemIndex}`,\n                                { legacyCode: 'conflict' },\n                            );\n                        }\n                        uploadedIndexes.add(itemIndex);\n\n                        const preparedIndex =\n                            preparedIndexByManifestIndex.get(itemIndex);\n                        const preparedItem =\n                            preparedIndex === undefined\n                                ? undefined\n                                : preparedBatch.itemsByIndex.get(preparedIndex);\n                        if (preparedIndex === undefined || !preparedItem) {\n                            throw new HttpError(\n                                400,\n                                `Batch write metadata was not found for index ${itemIndex}`,\n                                { legacyCode: 'bad_request' },","sourceCodeStart":665,"sourceCodeEnd":701,"githubUrl":"https://github.com/HeyPuter/puter/blob/908ec23eda38526170322c3edf71ba45ecb1ca95/src/backend/controllers/fs/FSController.ts#L665-L701","documentation":"Thrown during multipart /fs/batchWrite when two file parts in the same request resolve to the same manifest item index. Each manifest item may be uploaded exactly once; the second part for an already-seen index is rejected with HTTP 409. The item index is resolved from the field name and the part order, so duplicate field names or a client bug re-sending a file triggers it.","triggerScenarios":"Two multipart parts whose field names map to the same manifest index (e.g. two `file0` fields, or two parts whose order-position both resolve to index 0). A retry logic that re-appends a file without resetting state. A client that streams the same logical file twice under different field names that both parse to index 0.","commonSituations":"Frontend retry/resume code that re-appends a file part after an error. A form builder that duplicates file inputs. Manual curl invocations that include the same file twice.","solutions":["Ensure each manifest item index appears exactly once among the file parts.","On retry, build a fresh FormData rather than appending to the previous one.","Validate `uploadedIndexes`-equivalent state client-side before sending."],"exampleFix":"// before\nfiles.forEach((f, i) => fd.append(`file${i}`, f)); // if files contains dupes by index\n\n// after\nconst seen = new Set();\nfiles.forEach((f, i) => {\n  const idx = resolveIndex(f);\n  if (seen.has(idx)) return;\n  seen.add(idx);\n  fd.append(`file${idx}`, f);\n});","handlingStrategy":"validation","validationCode":"function dedupeIndexes(items) {\n  const seen = new Set();\n  return items.filter(i => {\n    if (seen.has(i.index)) return false;\n    seen.add(i.index); return true;\n  });\n}","typeGuard":null,"tryCatchPattern":"try { await batchWrite(form); }\ncatch (e) {\n  if (e?.code === 'conflict' && /Duplicate file content/.test(e.message)) { /* rebuild form without dup index */ }\n  else throw e;\n}","preventionTips":["Build the FormData from a deduplicated list keyed by manifest index.","On retry, construct a fresh FormData rather than appending to the old one.","Track sent indexes client-side to avoid re-sending."],"tags":["fs","batch-write","multipart","duplicate","conflict"],"backgroundTag":null,"analyzedSha":"908ec23eda38526170322c3edf71ba45ecb1ca95","analyzedAt":"2026-08-12T20:53:15.911Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}