{"record":{"id":"06fd679c81741552","repo":"HKUDS/DeepTutor","slug":"learningconflicterror-path-id-expected-int-curre","errorCode":null,"errorMessage":"LearningConflictError(path_id, expected, int(current[\"revision\"]) if current else 0)","messagePattern":"LearningConflictError\\(path_id, expected, int\\(current\\[\"revision\"\\]\\) if current else 0\\)","errorType":"error_code","errorClass":"LearningConflictError","httpStatus":null,"severity":"error","filePath":"deeptutor/learning/storage.py","lineNumber":513,"sourceCode":"                    cursor = conn.execute(\n                        \"\"\"\n                        UPDATE mastery_paths\n                        SET state_json = ?, revision = ?, updated_at = ?\n                        WHERE path_id = ? AND revision = ?\n                        \"\"\",\n                        (\n                            self._progress_payload(progress, revision, now),\n                            revision,\n                            now,\n                            path_id,\n                            expected,\n                        ),\n                    )\n                    if cursor.rowcount != 1:\n                        current = conn.execute(\n                            \"SELECT revision FROM mastery_paths WHERE path_id = ?\", (path_id,)\n                        ).fetchone()\n                        raise LearningConflictError(\n                            path_id, expected, int(current[\"revision\"]) if current else 0\n                        )\n                    event_type = \"path.saved\"\n                conn.execute(\n                    \"\"\"\n                    INSERT INTO mastery_events (\n                        path_id, revision, event_type, payload_json, created_at\n                    ) VALUES (?, ?, ?, '{}', ?)\n                    \"\"\",\n                    (path_id, revision, event_type, now),\n                )\n                conn.commit()\n            except Exception:\n                conn.rollback()\n                raise\n        progress.version = revision\n        progress.updated_at = now\n","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/learning/storage.py#L495-L531","documentation":"Optimistic-lock failure during save()'s UPDATE: the WHERE revision = expected clause matched no row because the stored revision moved past the expected value (or the row disappeared). LearningConflictError reports the path id, the expected revision, and the actual current revision (0 when absent).","triggerScenarios":"Thrown at deeptutor/learning/storage.py:513 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry after reloading the path's current revision","Coordinate writers through acquire_path_lease so only one mutates at a time"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","contentChangedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}