Debugging the D1_TYPE_ERROR
Understanding the Error
The error "Internal error: D1_TYPE_ERROR: Type 'object' not supported for value '[object Object]'" is coming from the quiz page backend (likely Cloudflare D1 database), not from our server.
This suggests:
- β Our server is working correctly
- β The request is reaching the quiz page
- β The quiz page backend is rejecting our answer format
Possible Causes
1. Wrong URL
You're using: https://tds-llm-analysis.s-anand.net/demo
This is a demo endpoint, not a quiz page. You need to:
- Go to the actual quiz page first
- Get the quiz page URL
- Use that URL in your request
2. Answer Format Issue
The quiz page might expect:
- A simple string instead of a JSON object
- A specific JSON structure
- A different data type
3. Quiz Page Backend Issue
The quiz page's database (D1) might have issues with:
- Complex nested objects
- Certain data types
- The way we're serializing the answer
How to Debug
Step 1: Check Server Logs
When you run the server, you should see detailed logs:
python -m app.main
Look for:
- "Submitting answer to: ..."
- "Payload: ..."
- "Response status: ..."
- "Error response: ..."
Step 2: Test with a Simple Answer
Try submitting a simple string answer first:
# Test with simple answer
$body = @{
email = "24f2005753@ds.study.iitm.ac.in"
secret = "EasyQuiz"
url = "https://tds-llm-analysis.s-anand.net/demo"
} | ConvertTo-Json
# But wait - you need the actual quiz page URL, not the demo endpoint!
Step 3: Verify the Quiz Page URL
The URL should be:
- A quiz page (like
https://tds-llm-analysis.s-anand.net/quiz/123) - NOT the demo endpoint (
/demo)
Step 4: Check What the Quiz Page Expects
- Open the quiz page in a browser
- Look at the page source
- Find the submit URL
- Check what format the answer should be in
Quick Fixes to Try
Fix 1: Use Correct URL
# Get the actual quiz page URL first
# Then use that URL, not the demo endpoint
$body = @{
email = "24f2005753@ds.study.iitm.ac.in"
secret = "EasyQuiz"
url = "https://tds-llm-analysis.s-anand.net/actual-quiz-page" # Change this!
} | ConvertTo-Json
Fix 2: Check Server Response
The server now logs more details. Check the terminal where python -m app.main is running to see:
- What payload is being sent
- What response is received
- Any error details
Fix 3: Test with curl for Better Error Messages
curl.exe -X POST http://127.0.0.1:8000/demo `
-H "Content-Type: application/json" `
-d '{\"email\":\"24f2005753@ds.study.iitm.ac.in\",\"secret\":\"EasyQuiz\",\"url\":\"https://tds-llm-analysis.s-anand.net/demo\"}' `
-v
The -v flag shows verbose output including headers and response details.
What I've Fixed
I've updated the code to:
- β
Better error handling in
_submit_answer - β More detailed logging
- β Better JSON serialization handling
- β Logs the full payload and response
Next Steps
- Check the server logs when you make the request
- Verify you're using the correct quiz page URL (not the demo endpoint)
- Look at the detailed error in the logs to see what the quiz page is rejecting
- Try with a simpler answer format if the logs show serialization issues
Expected Behavior
When working correctly:
- Server loads the quiz page
- Extracts the question
- Solves it
- Finds the submit URL
- Submits the answer
- Returns the response
The error you're seeing happens at step 5 - the quiz page backend is rejecting our submission.