HKUDS/DeepTutor · error · HTTPException

Module must contain at least one knowledge point

Error message

Module {mod.id!r} must contain at least one knowledge point

What it means

Validation error from _validate_runnable_modules: a LearningModule passed for a mastery path carries an empty knowledge_points list, which would leave the module with nothing to learn or schedule. The offending module is identified by its id in the message.

Solutions

  1. Ensure every module in the topic map defines at least one knowledge point before starting or importing a mastery path
  2. Remove or merge the empty module named in the error into a sibling module
  3. If the map was LLM-generated, regenerate the topic map and re-validate before persisting
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at deeptutor/api/routers/mastery_path.py:73 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/d50cdb9884a0d996. Report an issue: GitHub.

Appendix: source

Thrown at deeptutor/api/routers/mastery_path.py:73

        m_clean = {k: v for k, v in m.items() if k != "knowledge_points"}
        try:
            modules.append(LearningModule(knowledge_points=kps, **m_clean))
        except PydanticValidationError as exc:
            raise HTTPException(
                status_code=422,
                detail=f"Invalid module data in modules[{i}]: {exc.errors()}",
            ) from exc
    return modules


def _validate_runnable_modules(modules: list[LearningModule], *, status_code: int = 400) -> None:
    if not modules:
        raise HTTPException(
            status_code=status_code, detail="At least one learning module is required"
        )
    for mod in modules:
        if not mod.knowledge_points:
            raise HTTPException(
                status_code=status_code,
                detail=f"Module {mod.id!r} must contain at least one knowledge point",
            )


async def _cancel_active_learning_turn(book_id: str) -> None:
    from deeptutor.services.session import get_turn_runtime_manager

    learning_store = LearningStore()
    runtime = get_turn_runtime_manager()
    lease = await asyncio.to_thread(learning_store.get_path_lease, book_id)
    if lease is not None:
        if lease.session_id == "__path_api__":
            # Another administrative mutation owns the path. The caller's
            # acquisition attempt will return a deterministic HTTP 409.
            return
        await runtime.cancel_turn(lease.turn_id)
        # ``cancel_turn`` can finalize a restart orphan without an in-memory

View on GitHub (pinned to 3e82f13042)