Summary
POST /api/skill-progression/record and GET /api/skill-progression/user/<user_id> 500 with TypeError: Object of type SkillDifficulty is not JSON serializable. record_skill_completion stores the SkillDifficulty enum member in the returned dict, and the routes hand that dict to jsonify / json.dumps, which cannot serialize a plain Enum.
Evidence
src/utils/skill_progression.py:196:
skill_data = self.user_skills[user_id][skill_name]
skill_data["difficulty"] = difficulty # <-- the SkillDifficulty enum, not .value/.name
SkillDifficulty is a plain Enum (BEGINNER = 1, ..., EXPERT = 4), so it is not JSON-serializable by the stdlib encoder.
Reproduced (Python 3.13):
json.dumps({"difficulty": SkillDifficulty.EXPERT, "completed_at": "…",
"assessment_score": None, "progression_history": []})
TypeError: Object of type SkillDifficulty is not JSON serializable
Routes that return this dict:
src/routes/main_routes.py:613-626 — record returns jsonify({"skill_data": skill_data}) (line 620-626) → 500 after a successful record.
src/routes/main_routes.py:637-644 — get_user_progression returns skills (which contains the enum) → 500.
(Only progression_history entries store difficulty.name — a string — so the feature is one field away from working.)
Impact
- Recording a skill completion fails with HTTP 500 even though the record itself succeeded in memory.
- Retrieving a user's skill progression always returns 500 once any skill is recorded.
Suggested Fix
Store difficulty.value (or .name) at skill_progression.py:196, or serialize enums explicitly (e.g. SkillDifficulty.__members__ mapping / default=str). Add a test asserting json.dumps(skill_data) succeeds after record_skill_completion.
Summary
POST /api/skill-progression/recordandGET /api/skill-progression/user/<user_id>500 withTypeError: Object of type SkillDifficulty is not JSON serializable.record_skill_completionstores theSkillDifficultyenum member in the returned dict, and the routes hand that dict tojsonify/json.dumps, which cannot serialize a plainEnum.Evidence
src/utils/skill_progression.py:196:SkillDifficultyis a plainEnum(BEGINNER = 1, ...,EXPERT = 4), so it is not JSON-serializable by the stdlib encoder.Reproduced (Python 3.13):
Routes that return this dict:
src/routes/main_routes.py:613-626—recordreturnsjsonify({"skill_data": skill_data})(line 620-626) → 500 after a successful record.src/routes/main_routes.py:637-644—get_user_progressionreturnsskills(which contains the enum) → 500.(Only
progression_historyentries storedifficulty.name— a string — so the feature is one field away from working.)Impact
Suggested Fix
Store
difficulty.value(or.name) atskill_progression.py:196, or serialize enums explicitly (e.g.SkillDifficulty.__members__mapping /default=str). Add a test assertingjson.dumps(skill_data)succeeds afterrecord_skill_completion.