π OpenHands: AI-Driven Development
Feat: User id should be a str (Because it will probably be a UUID) (#6251)
tofarre21cbf67ee27
diff --git a/openhands/server/auth.py b/openhands/server/auth.pyindex b695cff89e..09bc0eb379 100644--- a/openhands/server/auth.py+++ b/openhands/server/auth.py@@ -5,8 +5,8 @@ from jwt.exceptions import InvalidTokenErrorfrom openhands.core.logger import openhands_logger as logger-def get_user_id(request: Request) -> int:- return getattr(request.state, 'github_user_id', 0)+def get_user_id(request: Request) -> str | None:+ return getattr(request.state, 'github_user_id', None)def get_sid_from_token(token: str, jwt_secret: str) -> str:diff --git a/openhands/server/routes/manage_conversations.py b/openhands/server/routes/manage_conversations.pyindex 61fedd8a4f..5cfc0ba82d 100644--- a/openhands/server/routes/manage_conversations.py+++ b/openhands/server/routes/manage_conversations.py@@ -222,7 +222,7 @@ async def _get_conversation_info(def _create_conversation_update_callback(- user_id: int, conversation_id: str+ user_id: str | None, conversation_id: str) -> Callable:def callback(*args, **kwargs):call_async_from_sync(@@ -235,7 +235,7 @@ def _create_conversation_update_callback(return callback-async def _update_timestamp_for_conversation(user_id: int, conversation_id: str):+async def _update_timestamp_for_conversation(user_id: str, conversation_id: str):conversation_store = await ConversationStoreImpl.get_instance(config, user_id)conversation = await conversation_store.get_metadata(conversation_id)conversation.last_updated_at = datetime.now(timezone.utc)diff --git a/openhands/server/session/manager.py b/openhands/server/session/manager.pyindex 250a7a4cc9..67358f61fb 100644--- a/openhands/server/session/manager.py+++ b/openhands/server/session/manager.py@@ -204,7 +204,7 @@ class SessionManager:return casync def join_conversation(- self, sid: str, connection_id: str, settings: Settings, user_id: int | None+ self, sid: str, connection_id: str, settings: Settings, user_id: str | None):logger.info(f'join_conversation:{sid}:{connection_id}')await self.sio.enter_room(connection_id, ROOM_KEY.format(sid=sid))@@ -343,7 +343,7 @@ class SessionManager:self._has_remote_connections_flags.pop(sid, None)async def maybe_start_agent_loop(- self, sid: str, settings: Settings, user_id: int | None+ self, sid: str, settings: Settings, user_id: str | None) -> EventStream:logger.info(f'maybe_start_agent_loop:{sid}')session: Session | None = Nonediff --git a/openhands/server/session/session.py b/openhands/server/session/session.pyindex 2767c05149..8318ab7731 100644--- a/openhands/server/session/session.py+++ b/openhands/server/session/session.py@@ -37,7 +37,7 @@ class Session:loop: asyncio.AbstractEventLoopconfig: AppConfigfile_store: FileStore- user_id: int | None+ user_id: str | Nonedef __init__(self,@@ -45,7 +45,7 @@ class Session:config: AppConfig,file_store: FileStore,sio: socketio.AsyncServer | None,- user_id: int | None = None,+ user_id: str | None = None,):self.sid = sidself.sio = siodiff --git a/openhands/storage/conversation/conversation_store.py b/openhands/storage/conversation/conversation_store.pyindex 40b5a23f12..8c55920efa 100644--- a/openhands/storage/conversation/conversation_store.py+++ b/openhands/storage/conversation/conversation_store.py@@ -41,6 +41,6 @@ class ConversationStore(ABC):@classmethod@abstractmethodasync def get_instance(- cls, config: AppConfig, user_id: int | None+ cls, config: AppConfig, user_id: str | None) -> ConversationStore:"""Get a store for the user represented by the token given"""diff --git a/openhands/storage/conversation/file_conversation_store.py b/openhands/storage/conversation/file_conversation_store.pyindex 858315b632..a9682c35c8 100644--- a/openhands/storage/conversation/file_conversation_store.py+++ b/openhands/storage/conversation/file_conversation_store.py@@ -92,7 +92,7 @@ class FileConversationStore(ConversationStore):@classmethodasync def get_instance(- cls, config: AppConfig, user_id: int | None+ cls, config: AppConfig, user_id: str | None) -> FileConversationStore:file_store = get_file_store(config.file_store, config.file_store_path)return FileConversationStore(file_store)diff --git a/openhands/storage/data_models/conversation_metadata.py b/openhands/storage/data_models/conversation_metadata.pyindex d19183b233..fb1f22a38f 100644--- a/openhands/storage/data_models/conversation_metadata.py+++ b/openhands/storage/data_models/conversation_metadata.py@@ -5,7 +5,7 @@ from datetime import datetime, timezone@dataclassclass ConversationMetadata:conversation_id: str- github_user_id: int+ github_user_id: str | Noneselected_repository: str | Nonetitle: str | None = Nonelast_updated_at: datetime | None = Nonediff --git a/openhands/storage/settings/file_settings_store.py b/openhands/storage/settings/file_settings_store.pyindex 1b4d4b6b0b..e0ea22d48c 100644--- a/openhands/storage/settings/file_settings_store.py+++ b/openhands/storage/settings/file_settings_store.py@@ -31,7 +31,7 @@ class FileSettingsStore(SettingsStore):@classmethodasync def get_instance(- cls, config: AppConfig, user_id: int | None+ cls, config: AppConfig, user_id: str | None) -> FileSettingsStore:file_store = get_file_store(config.file_store, config.file_store_path)return FileSettingsStore(file_store)diff --git a/openhands/storage/settings/settings_store.py b/openhands/storage/settings/settings_store.pyindex 1ff1aa85c3..cd64ae8e1e 100644--- a/openhands/storage/settings/settings_store.py+++ b/openhands/storage/settings/settings_store.py@@ -22,6 +22,6 @@ class SettingsStore(ABC):@classmethod@abstractmethodasync def get_instance(- cls, config: AppConfig, user_id: int | None+ cls, config: AppConfig, user_id: str | None) -> SettingsStore:"""Get a store for the user represented by the token given"""diff --git a/tests/unit/test_conversation.py b/tests/unit/test_conversation.pyindex 7610cf2525..86a5bf0bf8 100644--- a/tests/unit/test_conversation.py+++ b/tests/unit/test_conversation.py@@ -29,7 +29,7 @@ def _patch_store():'title': 'Some Conversation','selected_repository': 'foobar','conversation_id': 'some_conversation_id',- 'github_user_id': 12345,+ 'github_user_id': '12345','created_at': '2025-01-01T00:00:00','last_updated_at': '2025-01-01T00:01:00',}