Skip to content

Commit

Permalink
Fix error message on invalid token (#5302)
Browse files Browse the repository at this point in the history
  • Loading branch information
tofarr authored Nov 27, 2024
1 parent c70d160 commit 1a06906
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion openhands/server/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from openhands.events.observation import (
NullObservation,
)
from openhands.events.observation.error import ErrorObservation
from openhands.events.serialization import event_to_dict
from openhands.events.stream import AsyncEventStreamWrapper
from openhands.server.auth import get_sid_from_token, sign_token
Expand Down Expand Up @@ -41,7 +42,14 @@ async def init_connection(connection_id: str, data: dict):
if token:
sid = get_sid_from_token(token, config.jwt_secret)
if sid == '':
await sio.send({'error': 'Invalid token', 'error_code': 401})
await sio.emit(
'oh_event',
event_to_dict(
ErrorObservation(
content='Invalid token! (Maybe you need to specify a static jwt_secret?)'
)
),
)
return
logger.info(f'Existing session: {sid}')
else:
Expand Down

0 comments on commit 1a06906

Please sign in to comment.