HKUDS/DeepTutor · error · HTTPException

Invalid state transition: {capture.status} -> {requested_sta

Error message

Invalid state transition: {capture.status} -> {requested_status}

What it means

Error "Invalid state transition: {capture.status} -> {requested_status}" thrown in HKUDS/DeepTutor.

Source

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


@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:
        updated.user_note = req.user_note
        changed = True
    if req.rejected_reason is not None and req.rejected_reason != capture.rejected_reason:
        updated.rejected_reason = req.rejected_reason
        changed = True

    if not changed:

View on GitHub (pinned to 3e82f13042)

When it happens

Trigger: Thrown at deeptutor/api/routers/book.py:420 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/1dbb4247b639c5f1. Report an issue: GitHub.