{"record":{"id":"ec94479c692c1fbe","repo":"HKUDS/DeepTutor","slug":"filename-exceeds-the-max-material-bytes-102","errorCode":null,"errorMessage":"{filename} exceeds the {MAX_MATERIAL_BYTES // (1024 * 1024)} MB limit.","messagePattern":"(.+?) exceeds the (.+?) MB limit\\.","errorType":"http","errorClass":"HTTPException","httpStatus":413,"severity":"error","filePath":"deeptutor/api/routers/reading.py","lineNumber":193,"sourceCode":"async def upload_material(file: UploadFile = File(...)) -> MaterialDetail:  # noqa: B008\n    \"\"\"Ingest an uploaded document and return it ready to read.\n\n    The upload is streamed to a temp file with a running size check, so an\n    oversized file is rejected before it is fully buffered rather than after.\n    \"\"\"\n    filename = (file.filename or \"\").strip()\n    if not filename:\n        raise HTTPException(status_code=400, detail=\"The upload has no filename.\")\n\n    tmp_dir = Path(tempfile.mkdtemp(prefix=\"dt-reading-\"))\n    tmp_path = tmp_dir / Path(filename).name\n    written = 0\n    try:\n        with tmp_path.open(\"wb\") as sink:\n            while chunk := await file.read(_UPLOAD_CHUNK):\n                written += len(chunk)\n                if written > MAX_MATERIAL_BYTES:\n                    raise HTTPException(\n                        status_code=413,\n                        detail=(\n                            f\"{filename} exceeds the \"\n                            f\"{MAX_MATERIAL_BYTES // (1024 * 1024)} MB limit.\"\n                        ),\n                    )\n                sink.write(chunk)\n        if written == 0:\n            raise HTTPException(status_code=400, detail=f\"{filename} is empty.\")\n\n        store = _store()\n        manifest = store.ingest(tmp_path, filename=filename)\n        return _detail(store, manifest)\n    except HTTPException:\n        raise\n    except Exception as exc:\n        raise _http_error(exc) from exc\n    finally:","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/reading.py#L175-L211","documentation":"Error \"{filename} exceeds the {MAX_MATERIAL_BYTES // (1024 * 1024)} MB limit.\" thrown in HKUDS/DeepTutor.","triggerScenarios":"Thrown at deeptutor/api/routers/reading.py:193 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}