{"record":{"id":"3354c0613315fad6","repo":"BookStackApp/BookStack","slug":"errors-import-zip-data-too-large","errorCode":null,"errorMessage":"errors.import_zip_data_too_large","messagePattern":"errors\\.import_zip_data_too_large","errorType":"exception","errorClass":"ZipExportException","httpStatus":null,"severity":"error","filePath":"app/Exports/ZipExports/ZipExportReader.php","lineNumber":68,"sourceCode":"            $this->open = false;\n        }\n    }\n\n    /**\n     * @throws ZipExportException\n     */\n    public function readData(): array\n    {\n        $this->open();\n\n        $info = $this->zip->statName('data.json');\n        if ($info === false) {\n            throw new ZipExportException(trans('errors.import_zip_cant_decode_data'));\n        }\n\n        $maxSize = max(intval(config()->get('app.upload_limit')), 1) * 1000000;\n        if ($info['size'] > $maxSize) {\n            throw new ZipExportException(trans('errors.import_zip_data_too_large'));\n        }\n\n        // Validate json data exists, including metadata\n        $jsonData = $this->zip->getFromName('data.json') ?: '';\n        $importData = json_decode($jsonData, true);\n        if (!$importData) {\n            throw new ZipExportException(trans('errors.import_zip_cant_decode_data'));\n        }\n\n        return $importData;\n    }\n\n    public function fileExists(string $fileName): bool\n    {\n        return $this->zip->statName(\"files/{$fileName}\") !== false;\n    }\n\n    public function fileWithinSizeLimit(string $fileName): bool","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/BookStackApp/BookStack/blob/18f8469a1c72f8cc8497e9372635e6dea5028071/app/Exports/ZipExports/ZipExportReader.php#L50-L86","documentation":"ZipExportReader::readData() throws 'errors.import_zip_data_too_large' when the uncompressed size of the embedded data.json exceeds the application's configured upload limit (config('app.upload_limit') in megabytes, minimum 1). BookStack refuses to decode oversized import payloads to protect memory. This happens before json_decode runs.","triggerScenarios":"Importing a BookStack ZIP export whose data.json 'size' from statName() is greater than max(app.upload_limit,1) * 1000000 bytes — i.e. large exports with many pages/attachments metadata.","commonSituations":"Very large book/chapter exports from a big instance; app.upload_limit left at default (e.g. 10 or unset/0) while the export is larger; PHP memory limits also being tight on shared hosting.","solutions":["Raise 'upload_limit' in config/app.php (or APP_UPLOAD_LIMIT env) to exceed the data.json size in MB, then clear config caches (php artisan config:clear).","Split the export into smaller books/chapters on the source instance.","Confirm with `unzip -l export.zip` how large data.json is and set the limit accordingly.","If the limit won't budge, import content manually via the API instead."],"exampleFix":"// before (.env)\nAPP_UPLOAD_LIMIT=10\n// after\nAPP_UPLOAD_LIMIT=200","handlingStrategy":"validation","validationCode":"$zip = new ZipArchive();\n$zip->open($path);\n$stat = $zip->statName('data.json');\n$limitMb = max((int) config('app.upload_limit'), 1);\nif ($stat !== false && $stat['size'] > $limitMb * 1000000) {\n    throw new \\RuntimeException(\"data.json is {$stat['size']} bytes; exceeds {$limitMb}MB upload limit\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    $model = $reader->decodeDataToExportModel();\n} catch (\\BookStack\\Exports\\ZipExports\\ZipExportException $e) {\n    report($e); // surface which limit was hit\n    // raise APP_UPLOAD_LIMIT or split the export\n}","preventionTips":["Check data.json size with unzip -l before importing.","Set APP_UPLOAD_LIMIT generously on instances that import large exports.","Run php artisan config:clear after changing the limit.","Split very large books into smaller exports."],"tags":["zip-import","bookstack","upload-limit","config"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"18f8469a1c72f8cc8497e9372635e6dea5028071","analyzedAt":"2026-09-02T19:49:33.068Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}