{"record":{"id":"199fee097839b4f5","repo":"HKUDS/DeepTutor","slug":"rejected-archive-sanitized-filename-exc","errorCode":null,"errorMessage":"Rejected archive '{sanitized_filename}': {exc}","messagePattern":"Rejected archive '(.+?)': (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"deeptutor/api/routers/knowledge.py","lineNumber":285,"sourceCode":"            written = 0\n            for chunk in iter(lambda: file.file.read(8192), b\"\"):\n                written += len(chunk)\n                if written > max_size:\n                    raise HTTPException(\n                        status_code=400,\n                        detail=(\n                            f\"Archive '{sanitized_filename}' exceeds maximum size limit of \"\n                            f\"{format_bytes_human_readable(max_size)}\"\n                        ),\n                    )\n                tmp.write(chunk)\n\n        try:\n            result = safe_extract_zip(\n                tmp_path, target_dir, allowed_extensions=allowed_extensions or set()\n            )\n        except ArchiveTooLargeError as exc:\n            raise HTTPException(\n                status_code=400,\n                detail=f\"Rejected archive '{sanitized_filename}': {exc}\",\n            ) from exc\n        except zipfile.BadZipFile as exc:\n            raise HTTPException(\n                status_code=400,\n                detail=f\"'{sanitized_filename}' is not a valid zip archive.\",\n            ) from exc\n\n        if not result.extracted:\n            raise HTTPException(\n                status_code=400,\n                detail=f\"Archive '{sanitized_filename}' contained no supported files.\",\n            )\n        return result.extracted\n    finally:\n        if tmp_path is not None:\n            tmp_path.unlink(missing_ok=True)","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/knowledge.py#L267-L303","documentation":"400 raised by _save_zip_archive when safe_extract_zip throws ArchiveTooLargeError — the archive passed the raw size check but its decompressed contents exceed the extraction budget (zip-bomb / oversized-content protection).","triggerScenarios":"Uploading a zip that is small on disk but expands beyond the extraction limit (highly compressed data, nested archives), or contains more files/bytes than allowed.","commonSituations":"Zips of dense text corpora, nested zips, or a lowered extraction budget in config; benign large datasets mistaken for zip bombs.","solutions":["Reduce the decompressed size: remove unnecessary files, split into several archives","Check the extraction limit config and adjust if the content is legitimate","Avoid nested zips — extract locally and re-zip flat before upload"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import zipfile\ntotal = sum(i.file_size for i in zipfile.ZipFile(p).infolist())\nif total > MAX_DECOMPRESSED:\n    raise ValueError('decompressed size too large — remove files or split')","typeGuard":null,"tryCatchPattern":"resp = upload(zip_path)\nif resp.status_code == 400 and 'Rejected archive' in resp.text:\n    # decompressed content too large; repackage smaller/flatter\n    repackage(zip_path)","preventionTips":["Compute decompressed size before uploading","Avoid nested zips","Split dense corpora into several archives"],"tags":["knowledge-base","zip","zip-bomb","size-limit","http-400"],"backgroundTag":"zip-bomb-protection","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}