{"record":{"id":"d7a2cd0a9558fb77","repo":"HKUDS/DeepTutor","slug":"record-or-target-notebook-not-found","errorCode":null,"errorMessage":"Record or target notebook not found","messagePattern":"Record or target notebook not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"deeptutor/api/routers/notebook.py","lineNumber":425,"sourceCode":"        )\n        if not updated:\n            raise HTTPException(status_code=404, detail=\"Record not found\")\n        return {\"success\": True, \"record\": updated}\n    except HTTPException:\n        raise\n    except NotebookCorruptedError as exc:\n        raise _unreadable(exc)\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e))\n\n\n@router.post(\"/{notebook_id}/records/{record_id}/copy\")\nasync def copy_record(notebook_id: str, record_id: str, request: MoveRecordRequest):\n    \"\"\"Duplicate a record into another notebook under a fresh id.\"\"\"\n    try:\n        copied = notebook_manager.copy_record(notebook_id, record_id, request.target_notebook_id)\n        if not copied:\n            raise HTTPException(status_code=404, detail=\"Record or target notebook not found\")\n        return {\"success\": True, \"record\": copied}\n    except HTTPException:\n        raise\n    except NotebookCorruptedError as exc:\n        raise _unreadable(exc)\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=str(e))\n\n\n@router.post(\"/{notebook_id}/records/{record_id}/move\")\nasync def move_record(notebook_id: str, record_id: str, request: MoveRecordRequest):\n    \"\"\"Move a record from this notebook into another one.\"\"\"\n    try:\n        moved = notebook_manager.move_record(notebook_id, record_id, request.target_notebook_id)\n        if not moved:\n            raise HTTPException(status_code=404, detail=\"Record or target notebook not found\")\n        return {\"success\": True, \"record\": moved}\n    except HTTPException:","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/notebook.py#L407-L443","documentation":"404 from copy_record when notebook_manager.copy_record returns falsy: either the source record/notebook doesn't exist, or the target_notebook_id in the MoveRecordRequest body doesn't exist. The single message covers both cases.","triggerScenarios":"POST /{notebook_id}/records/{record_id}/copy where record_id is stale/removed or request.target_notebook_id names a notebook that was never created or deleted.","commonSituations":"Target notebook dropdown in the UI holding stale options; copying right after the source record was moved/deleted by another session; typos in target notebook id.","solutions":["Verify both notebook ids exist via GET /notebooks before copying","Refresh the source record list to confirm record_id is still present","Create the target notebook first if it doesn't exist"],"exampleFix":"// before\nawait client.post(f\"/notebook/{nb}/records/{rid}/copy\", json={\"target_notebook_id\": \"ghost\"})\n// after\nawait client.post(\"/notebook/create\", json={\"name\": \"Target\"})\ntid = (await client.get(\"/notebooks\")).json()[\"notebooks\"][-1][\"id\"]\nawait client.post(f\"/notebook/{nb}/records/{rid}/copy\", json={\"target_notebook_id\": tid})","handlingStrategy":"validation","validationCode":"ids = {b[\"id\"] for b in (await client.get(\"/notebooks\")).json()[\"notebooks\"]}\nif request_target not in ids:\n    await create_notebook(request_target)","typeGuard":null,"tryCatchPattern":"resp = await client.post(copy_url, json=payload)\nif resp.status_code == 404:\n    await refresh_notebooks_and_records()","preventionTips":["Populate target-notebook pickers from a live /notebooks listing","Re-check the source record still exists right before copy"],"tags":["notebook","http-404","copy","fastapi"],"backgroundTag":"http-404-not-found","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}