{"record":{"id":"059dee638a469a69","repo":"BookStackApp/BookStack","slug":"could-not-identify-content-in-zip-file-data","errorCode":null,"errorMessage":"Could not identify content in ZIP file data.","messagePattern":"Could not identify content in ZIP file data\\.","errorType":"exception","errorClass":"ZipExportException","httpStatus":null,"severity":"error","filePath":"app/Exports/ZipExports/ZipExportReader.php","lineNumber":130,"sourceCode":"\n        return (new WebSafeMimeSniffer())->sniff($sniffContent);\n    }\n\n    /**\n     * @throws ZipExportException\n     */\n    public function decodeDataToExportModel(): ZipExportBook|ZipExportChapter|ZipExportPage\n    {\n        $data = $this->readData();\n        if (isset($data['book'])) {\n            return ZipExportBook::fromArray($data['book']);\n        } else if (isset($data['chapter'])) {\n            return ZipExportChapter::fromArray($data['chapter']);\n        } else if (isset($data['page'])) {\n            return ZipExportPage::fromArray($data['page']);\n        }\n\n        throw new ZipExportException(\"Could not identify content in ZIP file data.\");\n    }\n}\n","sourceCodeStart":112,"sourceCodeEnd":133,"githubUrl":"https://github.com/BookStackApp/BookStack/blob/18f8469a1c72f8cc8497e9372635e6dea5028071/app/Exports/ZipExports/ZipExportReader.php#L112-L133","documentation":"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.","triggerScenarios":"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).","commonSituations":"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).","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."],"exampleFix":"// before (data.json)\n{\"meta\": {...}, \"books\": {...}}\n// after\n{\"meta\": {...}, \"book\": {\"id\": 1, \"name\": \"My Book\", ...}}","handlingStrategy":"validation","validationCode":"$data = json_decode($zip->getFromName('data.json') ?: '', true);\nif (!isset($data['book'], $data['chapter'], $data['page'])) {\n    // at least one must be set\n    if (empty(array_intersect(['book','chapter','page'], array_keys($data ?: [])))) {\n        throw new \\RuntimeException('data.json has no book/chapter/page key');\n    }\n}","typeGuard":"function hasRecognizedExportContent(?array $data): bool {\n    return is_array($data) && (isset($data['book']) || isset($data['chapter']) || isset($data['page']));\n}","tryCatchPattern":"try {\n    $model = $reader->decodeDataToExportModel();\n} catch (\\BookStack\\Exports\\ZipExports\\ZipExportException $e) {\n    if ($e->getMessage() === 'Could not identify content in ZIP file data.') {\n        // inspect top-level keys of data.json\n    }\n}","preventionTips":["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."],"tags":["zip-import","bookstack","schema","unrecognized-content"],"backgroundTag":"unrecognized-import-schema","analyzedSha":"18f8469a1c72f8cc8497e9372635e6dea5028071","analyzedAt":"2026-09-02T19:49:33.068Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}