{"record":{"id":"1d3913e7a17e4be2","repo":"apache/seatunnel","slug":"session-not-found-session-id","errorCode":null,"errorMessage":"Session not found: {session_id}","messagePattern":"Session not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"seatunnel-cli/seatunnel_cli/memory.py","lineNumber":267,"sourceCode":"        redacted_history = _redact_conversation_history(conversation_history)\n        redacted_config = redact_credentials(last_config) if last_config else last_config\n\n        data = {\n            \"session_id\": self.current_session_id,\n            \"created_at\": existing.get(\"created_at\", _now_iso()),\n            \"last_active\": _now_iso(),\n            \"summary\": existing.get(\"summary\", \"\"),\n            \"message_count\": len(conversation_history),\n            \"last_config\": redacted_config,\n            \"conversation_history\": redacted_history,\n        }\n        _atomic_write(path, data)\n\n    def load_session(self, session_id: str) -> tuple[list[dict], str | None]:\n        \"\"\"Load a session. Returns (conversation_history, last_config).\"\"\"\n        path = self.sessions_dir / f\"{session_id}.json\"\n        if not path.exists():\n            raise FileNotFoundError(f\"Session not found: {session_id}\")\n        with open(path, \"r\", encoding=\"utf-8\") as f:\n            data = json.load(f)\n        self.current_session_id = session_id\n        return data.get(\"conversation_history\", []), data.get(\"last_config\")\n\n    def list_sessions(self, limit: int = 10) -> list[dict]:\n        result = []\n        for f in sorted(self.sessions_dir.glob(\"*.json\"), reverse=True):\n            try:\n                with open(f, \"r\", encoding=\"utf-8\") as fh:\n                    data = json.load(fh)\n                result.append({\n                    \"session_id\": data.get(\"session_id\", f.stem),\n                    \"created_at\": data.get(\"created_at\", \"\"),\n                    \"last_active\": data.get(\"last_active\", \"\"),\n                    \"summary\": data.get(\"summary\", \"\"),\n                    \"message_count\": data.get(\"message_count\", 0),\n                })","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-cli/seatunnel_cli/memory.py#L249-L285","documentation":"MemoryManager.load_session() resolves the session file as <sessions_dir>/<session_id>.json and raises FileNotFoundError if that file does not exist. It signals that the requested conversation session was never created or has been deleted, so no history can be restored.","triggerScenarios":"Calling load_session(session_id) with an ID whose JSON file is absent from the sessions directory — e.g. resuming with a mistyped or truncated ID, a session from another profile/machine, or one removed by cleanup.","commonSituations":"Manually copying commands between machines with different session stores; session pruned by retention/cleanup; typos when passing --session ids; switching SEATUNNEL home/config dirs.","solutions":["Call list_sessions() to find the correct existing session ID","Start a new session instead of resuming if the old one is gone","Verify you are pointing at the same sessions directory/config profile that created the session","Catch FileNotFoundError and fall back to creating a fresh session"],"exampleFix":"// before\nhistory, cfg = memory.load_session(args.session)\n// after\ntry:\n    history, cfg = memory.load_session(args.session)\nexcept FileNotFoundError:\n    history, cfg = memory.start_new_session()","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\nsessions_dir = memory.sessions_dir\nassert (sessions_dir / f\"{session_id}.json\").exists(), f\"Unknown session {session_id}\"","typeGuard":"def session_exists(memory, session_id: str) -> bool:\n    return (memory.sessions_dir / f\"{session_id}.json\").exists()","tryCatchPattern":"try:\n    history, cfg = memory.load_session(session_id)\nexcept FileNotFoundError:\n    available = memory.list_sessions()\n    print(f\"Session {session_id} not found. Recent: {available}\")\n    history, cfg = [], None","preventionTips":["Pick session IDs from list_sessions() output instead of retyping them","Back up the sessions directory if conversations matter","Confirm the same config/home directory is used across invocations"],"tags":["file-not-found","session","state"],"backgroundTag":"file-not-found","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}