SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
This error when trying to add questions from the dashboard.
The backend is returning an HTML error page instead of JSON. This happens because:
- The backend needs to be restarted to load the new
ai_feedbackmodel - OR the backend crashed on startup due to the new imports
If backend is running, press Ctrl+C to stop it.
cd Backend
uvicorn main:app --reloadLook for these messages:
✅ Good (Success):
🚀 App started! Creating tables...
✅ All tables created successfully (including ai_feedback table)
INFO: Application startup complete.
❌ Bad (Error):
Error loading model...
Traceback...
cd Backend
source venv/bin/activate # or on Windows: venv\Scripts\activate
python test_ai_feedback_model.pyThis will tell you exactly what's wrong.
Issue 1: Module not found
ModuleNotFoundError: No module named 'sqlalchemy'
Fix: Activate virtual environment
source venv/bin/activateIssue 2: Database connection error
Could not connect to database
Fix: Check .env file has correct DATABASE_URL
Issue 3: Import circular dependency
Fix: Check the error message and let me know what it says
Once backend restarts successfully, test the question creation:
curl -X POST http://localhost:8000/api/questions \
-H "Content-Type: application/json" \
-d '{
"text": "Test question",
"type": "mcq",
"document_id": "your-document-uuid",
"correct_answer": "A",
"options": {"A": "Option A", "B": "Option B"}
}'Should return JSON, not HTML.
- Stop backend (Ctrl+C)
- Restart backend (
uvicorn main:app --reload) - Check logs - Look for "✅ All tables created"
- Try adding question again from dashboard
If still getting error, send me the backend startup logs!