HKUDS/DeepTutor · error · ValueError

session_id and turn_id are required for a path lease

Error message

session_id and turn_id are required for a path lease

What it means

acquire_path_lease was called with a blank session_id or turn_id after stripping: path leases exist to pin a path to one conversation turn, so both identifiers are mandatory.

Solutions

  1. Supply both the session id and turn id when acquiring a lease
  2. If exclusion without a conversation is needed, use the bind_session=False administrative path
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at deeptutor/learning/storage.py:854 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/00acb63fa3d28a04. Report an issue: GitHub.

Appendix: source

Thrown at deeptutor/learning/storage.py:854

        with self._connect() as conn:
            row = conn.execute(
                "SELECT * FROM mastery_path_leases WHERE path_id = ?", (path_id,)
            ).fetchone()
        return self._lease_from_row(row)

    def acquire_path_lease(
        self,
        path_id: str,
        session_id: str,
        turn_id: str,
        *,
        bind_session: bool = True,
    ) -> MasteryPathLease:
        path_id = self._validate_id(path_id)
        session_id = str(session_id or "").strip()
        turn_id = str(turn_id or "").strip()
        if not session_id or not turn_id:
            raise ValueError("session_id and turn_id are required for a path lease")
        if bind_session:
            self.bind_session(path_id, session_id, owns_path=False)
        else:
            # Administrative mutations need exclusion without creating a fake
            # conversation association.
            with self.transaction(path_id, create=True):
                pass
        now = time.time()
        with self._connect() as conn:
            conn.execute("BEGIN IMMEDIATE")
            try:
                row = conn.execute(
                    "SELECT * FROM mastery_path_leases WHERE path_id = ?", (path_id,)
                ).fetchone()
                existing = self._lease_from_row(row)
                if existing is not None and existing.turn_id != turn_id:
                    raise PathLeaseConflictError(existing)
                conn.execute(

View on GitHub (pinned to 3e82f13042)