HKUDS/DeepTutor · error · HTTPException

Learning capture not found

Error message

Learning capture not found

What it means

HTTP 404 raised by update_learning_capture in deeptutor/api/routers/book.py:413 when storage.load_learning_capture(book_id, capture_id) returns None. The capture_id does not match any stored capture for that book, so the PATCH cannot be applied.

Solutions

  1. Refresh the capture list to get valid capture ids
  2. Handle 404 by dropping the stale local capture reference
  3. Verify book_id and capture_id pairing
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at deeptutor/api/routers/book.py:413 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/4c4d3c4a95306a71. Report an issue: GitHub.

Appendix: source

Thrown at deeptutor/api/routers/book.py:413

        chapter_title=req.chapter_title or chapter_title,
        user_note=req.user_note.strip(),
        content_hash=content_hash,
        status=status,
    )
    storage.upsert_learning_capture(capture)
    return {"capture": _capture_payload(capture)}


@router.patch("/books/{book_id}/learning-captures/{capture_id}")
async def update_learning_capture(
    book_id: str,
    capture_id: str,
    req: LearningCaptureUpdateRequest,
) -> dict[str, Any]:
    storage = get_book_storage()
    capture = storage.load_learning_capture(book_id, capture_id)
    if capture is None:
        raise HTTPException(status_code=404, detail="Learning capture not found")

    requested_status = _coerce_capture_status(req.status) if req.status is not None else None
    if requested_status is not None and not _is_capture_transition_allowed(
        capture.status,
        requested_status,
    ):
        raise HTTPException(
            status_code=400,
            detail=(f"Invalid state transition: {capture.status} -> {requested_status}"),
        )

    changed = False
    updated = capture.model_copy(deep=True)

    if requested_status is not None and requested_status != capture.status:
        updated.status = requested_status
        changed = True
    if req.user_note is not None and req.user_note != capture.user_note:

View on GitHub (pinned to 3e82f13042)