{"record":{"id":"8e67a3069cbc9ae9","repo":"paperclipai/paperclip","slug":"this-exact-package-was-already-imported-by-a-compl","errorCode":null,"errorMessage":"This exact package was already imported by a completed transfer. Re-export the package to import it again.","messagePattern":"This exact package was already imported by a completed transfer\\. Re-export the package to import it again\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"cli/src/commands/client/company.ts","lineNumber":1163,"sourceCode":" * with the transfer id once the server holds every part.\n */\nexport async function uploadCompanyImportTransfer(\n  api: Pick<PaperclipApiClient, \"post\" | \"putRaw\">,\n  zipBytes: Uint8Array,\n  opts: { onProgress?: (progress: ImportTransferUploadProgress) => void } = {},\n): Promise<string> {\n  const manifest = buildImportTransferManifest(zipBytes);\n  const created = await api.post<CompanyImportTransferCreated>(\n    `/api/companies${COMPANY_IMPORT_TRANSFERS_ROUTE_PATH}`,\n    manifest,\n  );\n  if (!created) {\n    throw new Error(\"Import transfer declaration returned no data.\");\n  }\n  if (created.alreadyCompleted) {\n    // The server keys transfers by content, and this exact zip already\n    // finished an apply — its spooled parts are gone, so it cannot re-run.\n    throw new Error(\n      \"This exact package was already imported by a completed transfer. Re-export the package to import it again.\",\n    );\n  }\n  const missing = new Set(created.missingParts);\n  let uploadedParts = manifest.parts.length - missing.size;\n  let uploadedBytes = manifest.parts.reduce(\n    (sum, part) => (missing.has(part.index) ? sum : sum + part.byteSize),\n    0,\n  );\n  for (const part of manifest.parts) {\n    if (!missing.has(part.index)) continue;\n    const offset = part.index * manifest.partSizeBytes;\n    const bytes = zipBytes.subarray(offset, offset + part.byteSize);\n    let lastError: unknown = null;\n    let uploaded = false;\n    for (let attempt = 0; attempt < IMPORT_TRANSFER_PART_ATTEMPTS && !uploaded; attempt += 1) {\n      try {\n        await api.putRaw(","sourceCodeStart":1145,"sourceCodeEnd":1181,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/client/company.ts#L1145-L1181","documentation":"Thrown by uploadCompanyImportTransfer when the server reports created.alreadyCompleted === true. The server content-addresss transfers; if this exact zip already finished an apply, its spooled parts have been deleted, so the parts cannot be re-uploaded and the apply cannot be re-run. The fix is to produce a fresh package.","triggerScenarios":"Re-running an import with the exact same zip file (byte-identical) after a previous apply completed. Reusing a cached .zip from an earlier export. A backup routine that re-uploads the same nightly artifact twice. Any idempotent retry of an apply that already succeeded.","commonSituations":"An operator re-runs a failed-looking import that actually completed. CI uploads the same artifact twice. A user double-clicks the apply button. A scheduled job produces a deterministic zip and runs more than once against the same content.","solutions":["Re-export the source to produce a new zip (content hash will differ if anything changed) and import that.","If the source is unchanged, the previous import already succeeded — verify the company state instead of re-importing.","Add a tiny non-functional change (a timestamp/manifest entry) to force a different content hash if you truly need to re-run.","Check the import history on the server to confirm the prior apply outcome before re-exporting."],"exampleFix":"# before (reusing stale zip)\npaperclipai company import nightly-backup-2024-01-01.zip --yes\n# after (fresh export first)\npaperclipai company export --company cmp_abc --out fresh.zip\npaperclipai company import fresh.zip --yes","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await uploadCompanyImportTransfer(api, zipBytes);\n} catch (err) {\n  if (err instanceof Error && /already imported by a completed transfer/.test(err.message)) {\n    console.warn(\"Package already imported. Re-export the source to re-run, or verify state on the server.\");\n    return;\n  }\n  throw err;\n}","preventionTips":["Treat the prior apply as authoritative when content is unchanged.","Re-export packages fresh for each import run rather than reusing zips.","Track apply outcomes in your orchestration layer to skip duplicate uploads."],"tags":["cli","company-import","transfer","idempotency","duplicate"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}