BookStackApp/BookStack · error · ZipExportException

Failed to add files for ZIP export, received error:

Error message

Failed to add files for ZIP export, received error: 

What it means

ZipExportException thrown in ZipExportBuilder::build when extracting/adding the export's attachment/image files to the archive fails; partial files already added are removed from the zip before throwing. The underlying error comes from the files->extractEach callback (e.g. missing or unreadable source file on disk).

Source

Thrown at app/Exports/ZipExports/ZipExportBuilder.php:107

        try {
            $this->files->extractEach(function ($filePath, $fileRef) use ($zip, &$toRemove, &$addedNames) {
                $entryName = "files/$fileRef";
                $zip->addFile($filePath, $entryName);
                $toRemove[] = $filePath;
                $addedNames[] = $entryName;
            });
        } catch (\Exception $exception) {
            // Cleanup the files we've processed so far and respond back with error
            foreach ($toRemove as $file) {
                unlink($file);
            }
            foreach ($addedNames as $name) {
                $zip->deleteName($name);
            }
            $zip->close();
            unlink($zipFile);
            throw new ZipExportException("Failed to add files for ZIP export, received error: " . $exception->getMessage());
        }

        $zip->close();

        foreach ($toRemove as $file) {
            unlink($file);
        }

        return $zipFile;
    }
}

View on GitHub (pinned to 18f8469a1c)

Solutions

  1. Check the storage/uploads files referenced by the export still exist on disk
  2. Verify read permissions on uploaded file storage
  3. Inspect the wrapped exception's error text for the specific file that failed
  4. Re-upload missing attachments then retry the export
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at app/Exports/ZipExports/ZipExportBuilder.php:107 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BookStackApp/BookStack@18f8469a1c (2026-09-02). Data as JSON: /api/errors/912b41ea269e289a. Report an issue: GitHub.