{"record":{"id":"9d1da9bde82f8037","repo":"Budibase/budibase","slug":"backup-incomplete-cannot-download","errorCode":null,"errorMessage":"Backup incomplete - cannot download.","messagePattern":"Backup incomplete - cannot download\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/pro/src/sdk/backups/backup.ts","lineNumber":166,"sourceCode":"      }\n    }\n    page = expiredBackups.nextPage\n  } while (page)\n\n  return result\n}\n\nasync function fetchWorkspaceBackups(\n  workspaceId: string,\n  opts?: BackupFetchOpts\n) {\n  return backups.fetchWorkspaceBackups(workspaceId, opts)\n}\n\nasync function getBackupDownloadStream(backupId: string) {\n  const metadata = await backups.getWorkspaceBackupMetadata(backupId)\n  if (!metadata.filename) {\n    throw new Error(\"Backup incomplete - cannot download.\")\n  }\n  const { stream } = await objectStore.getReadStream(\n    objectStore.ObjectStoreBuckets.BACKUPS,\n    metadata.filename\n  )\n  return { metadata, stream }\n}\n\nasync function downloadWorkspaceBackup(backupId: string): Promise<string> {\n  const { stream } = await getBackupDownloadStream(backupId)\n  const path = join(objectStore.budibaseTempDir(), utils.newid())\n  const writeStream = fs.createWriteStream(path)\n  return new Promise((resolve, reject) => {\n    stream.on(\"error\", reject)\n    writeStream.on(\"error\", reject)\n    stream.pipe(writeStream).on(\"close\", () => resolve(path))\n  })\n}","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/pro/src/sdk/backups/backup.ts#L148-L184","documentation":"Downloading a workspace backup requires the backup object to exist in object storage, identified by metadata.filename. When the backup metadata document exists but has no filename (the backup never finished uploading), getBackupDownloadStream throws this error because there is nothing stored to stream. It guards against serving empty/corrupt downloads for incomplete backups.","triggerScenarios":"Calling getBackupDownloadStream(backupId) where backups.getWorkspaceBackupMetadata(backupId) returns a metadata doc whose filename field is undefined/empty — typically because the backup creation job failed or was interrupted after the metadata doc was written but before the file was uploaded to the BACKUPS bucket.","commonSituations":"Backup process crashed or the worker restarted mid-upload; object store (MinIO/S3) was unavailable during backup; user clicks download for a backup still in progress or listed in the UI despite a failed upload.","solutions":["Verify the backup completed (check metadata status / timestamps) and re-run the backup to produce a complete file.","Check that the BACKUPS bucket in the object store (MinIO/S3) is reachable and contains the file; fix storage connectivity if the upload failed.","Delete the incomplete backup record and create a new one instead of retrying the download.","If uploads are repeatedly failing, inspect worker logs at backup time for object-store errors and retry with sufficient disk/network."],"exampleFix":"// before\nconst { stream } = await getBackupDownloadStream(backupId)\n// after\nconst metadata = await backups.getWorkspaceBackupMetadata(backupId)\nif (!metadata.filename) {\n  throw new Error(\"Backup incomplete; please create a new backup\")\n}\nconst { stream } = await getBackupDownloadStream(backupId)","handlingStrategy":"validation","validationCode":"const metadata = await backups.getWorkspaceBackupMetadata(backupId)\nif (!metadata.filename) {\n  throw new Error(`Backup ${backupId} is incomplete; create a new backup`)\n}","typeGuard":"function isDownloadable(m: { filename?: string }): m is { filename: string } {\n  return typeof m.filename === \"string\" && m.filename.length > 0\n}","tryCatchPattern":"try {\n  const { stream } = await getBackupDownloadStream(backupId)\n} catch (err) {\n  if (err.message === \"Backup incomplete - cannot download.\") {\n    // prompt user to re-run the backup\n  } else throw err\n}","preventionTips":["Only show the download action for backups whose creation completed successfully","Monitor object-store upload errors during backup creation","Delete/clean up metadata records for failed backups"],"tags":["backups","object-store","download"],"backgroundTag":"backup-incomplete","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}