BookStackApp/BookStack · error · ZipExportException
Could not identify content in ZIP file data.
Error message
Could not identify content in ZIP file data.
What it means
ZipExportReader::decodeDataToExportModel() inspects the decoded data.json for one of the keys 'book', 'chapter', or 'page' (after handling meta) and builds the matching ZipExport* model. If none of these keys is present it throws a plain ZipExportException with the literal message 'Could not identify content in ZIP file data.' — the archive is valid JSON but not a recognized BookStack export payload.
Source
Thrown at app/Exports/ZipExports/ZipExportReader.php:130
return (new WebSafeMimeSniffer())->sniff($sniffContent);
}
/**
* @throws ZipExportException
*/
public function decodeDataToExportModel(): ZipExportBook|ZipExportChapter|ZipExportPage
{
$data = $this->readData();
if (isset($data['book'])) {
return ZipExportBook::fromArray($data['book']);
} else if (isset($data['chapter'])) {
return ZipExportChapter::fromArray($data['chapter']);
} else if (isset($data['page'])) {
return ZipExportPage::fromArray($data['page']);
}
throw new ZipExportException("Could not identify content in ZIP file data.");
}
}
View on GitHub (pinned to 18f8469a1c)
Solutions
- Open data.json and confirm it has a top-level 'book', 'chapter', or 'page' key.
- Regenerate the export from BookStack's export UI/command so the schema matches.
- Fix key names if the file was hand-crafted (singular 'book'/'chapter'/'page', not plural).
- Check BookStack version compatibility — export/import schema changed between major versions.
Example fix
// before (data.json)
{"meta": {...}, "books": {...}}
// after
{"meta": {...}, "book": {"id": 1, "name": "My Book", ...}} Defensive patterns
Strategy: validation
Validate before calling
$data = json_decode($zip->getFromName('data.json') ?: '', true);
if (!isset($data['book'], $data['chapter'], $data['page'])) {
// at least one must be set
if (empty(array_intersect(['book','chapter','page'], array_keys($data ?: [])))) {
throw new \RuntimeException('data.json has no book/chapter/page key');
}
} Type guard
function hasRecognizedExportContent(?array $data): bool {
return is_array($data) && (isset($data['book']) || isset($data['chapter']) || isset($data['page']));
} Try / catch
try {
$model = $reader->decodeDataToExportModel();
} catch (\BookStack\Exports\ZipExports\ZipExportException $e) {
if ($e->getMessage() === 'Could not identify content in ZIP file data.') {
// inspect top-level keys of data.json
}
} Prevention
- Use singular keys 'book'/'chapter'/'page' in hand-crafted exports.
- Regenerate exports with the official BookStack export path.
- Pin matching BookStack versions between export and import.
- Don't strip keys from data.json when trimming exports.
When it happens
Trigger: data.json decodes fine but contains none of the keys book/chapter/page at the top level (e.g. only {"meta":...}, an empty array passed the earlier falsy check, or a differently structured JSON).
Common situations: Importing a ZIP from another tool; a data.json that was trimmed to only metadata; a future/older export schema mismatch; manually crafted import files using wrong key names (e.g. 'books' or 'pages' plural).
Related errors
- errors.import_zip_cant_decode_data
- errors.import_zip_data_too_large
- errors.import_validation_failed
- Must not have a parent set for a Book import.
- Parent book required for chapter import.
AI-assisted analysis of BookStackApp/BookStack@18f8469a1c (2026-09-02).
Data as JSON: /api/errors/059dee638a469a69.
Report an issue: GitHub.