HKUDS/DeepTutor · error · HTTPException
source_text is required
Error message
source_text is required
What it means
HTTP 422 raised by create_learning_capture in deeptutor/api/routers/book.py:362 when the normalized source_text of a LearningCaptureCreateRequest is empty. A capture records an excerpt of source material, so a blank source_text is rejected before storage.
Solutions
- Send the block's source text with the capture request
- Guard client-side against submitting empty selections
- Trim whitespace client-side; blank-only text is rejected
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at deeptutor/api/routers/book.py:362 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/853ce04f10278a9c.
Report an issue: GitHub.
Appendix: source
Thrown at deeptutor/api/routers/book.py:362
return {"captures": [_capture_payload(capture) for capture in captures]}
@router.post("/books/{book_id}/learning-captures")
async def create_learning_capture(
book_id: str,
req: LearningCaptureCreateRequest,
) -> dict[str, Any]:
engine = get_book_engine()
if engine.load_book(book_id) is None:
raise HTTPException(status_code=404, detail="Book not found")
page = engine.load_page(book_id, req.page_id)
if page is None:
raise HTTPException(status_code=404, detail="Page not found")
source_text = _normalize_capture_text(req.source_text)
if not source_text:
raise HTTPException(status_code=400, detail="source_text is required")
book_title, chapter_title, default_source_locator = _derive_capture_title_values(
book_id=book_id,
page_id=req.page_id,
block_id=req.block_id,
)
source_locator = req.source_locator.strip() or default_source_locator
status = _coerce_capture_status(req.status) or LearningCaptureStatus.CAPTURED
content_hash = _build_capture_hash(
book_id,
req.page_id,
req.block_id,
source_locator,
source_text,
)
View on GitHub (pinned to 3e82f13042)