Spaces:
Sleeping
Sleeping
Fix JWT session creation causing 500 errors
Browse filesFix session creation workflow:
- Store session data in JWT session manager after creation
- Update get_session to check stored session data
- Prevent 500 errors when creating new sessions
Resolves 'Failed to create session' 500 errors in frontend
v1.0.9
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- app/core/jwt_session.py +10 -2
app/core/jwt_session.py
CHANGED
|
@@ -46,12 +46,20 @@ class JWTSessionManager:
|
|
| 46 |
"conversation_started": False
|
| 47 |
}
|
| 48 |
|
| 49 |
-
#
|
|
|
|
|
|
|
|
|
|
| 50 |
return session_id
|
| 51 |
|
| 52 |
def get_session(self, session_id: str) -> Optional[Dict]:
|
| 53 |
"""Retrieve session data (for compatibility - JWT will be handled at API level)."""
|
| 54 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
if session_id in self.conversations:
|
| 56 |
return {
|
| 57 |
"session_id": session_id,
|
|
|
|
| 46 |
"conversation_started": False
|
| 47 |
}
|
| 48 |
|
| 49 |
+
# Store the session data for retrieval
|
| 50 |
+
self.session_data = getattr(self, 'session_data', {})
|
| 51 |
+
self.session_data[session_id] = session_data
|
| 52 |
+
|
| 53 |
return session_id
|
| 54 |
|
| 55 |
def get_session(self, session_id: str) -> Optional[Dict]:
|
| 56 |
"""Retrieve session data (for compatibility - JWT will be handled at API level)."""
|
| 57 |
+
# Check stored session data first
|
| 58 |
+
session_data_store = getattr(self, 'session_data', {})
|
| 59 |
+
if session_id in session_data_store:
|
| 60 |
+
return session_data_store[session_id]
|
| 61 |
+
|
| 62 |
+
# Fallback: check if conversation exists
|
| 63 |
if session_id in self.conversations:
|
| 64 |
return {
|
| 65 |
"session_id": session_id,
|