teerasej / run-with-p-toon

0 stars 0 forks source link

เจอ id: KeyError ในฝั่ง Server #15

Closed teerasej closed 6 years ago

teerasej commented 6 years ago
'id': KeyError
Traceback (most recent call last):
File "/var/task/handler.py", line 52, in registerRunner
fb_user_id = event['id']
KeyError: 'id'
teerasej commented 6 years ago

ปัจจุบันพลกับอู่ยังไม่สามารถ reproduce error ตัวนี้ได้

paponyon commented 6 years ago

สิ่งที่ทำในตอนนี้คือ

  1. print log ค่า json ที่ถูกส่งมาจาก frontend เพื่อดู input ว่าหน้าตาเป็นแบบไหนที่ทำให้เกิด KeyError
  2. check if Dict contain Key['id']
paponyon commented 6 years ago

@teerasej ปัญหาคือเวลาที่คนกด "ข้ามไปวิ่งเลย" (ในกรณีที่ไม่ต้องการ login ด้วย facebook) ความจะส่ง name="anonymous" มาด้วย ตอนนี้ส่งมาเป็น {} ทำให้เจอ Keyerror

วิธีแก้ ในกรณีที่คนกด "ข้ามไปวิ่งเลย" ให้ส่ง json structure ดังนี้

{ "id": "", "name": "anonymous", "age_range": "", "gender": "", "picture": "" }

หรือ

{}

*ตอนนี้ปรับหลังบ้านให้รองรับ anonymous ด้วยรูปแบบ {} แล้ว