🌊 Волна 1: backend продукты + security (12 багов)
Продуктовые фиксы: - hints_not_incremented: лимит 3 подсказки теперь работает (hints.py) - assistant_quota_burned_on_ai_failure: лимит не списывается при ошибке AI (assistant.py) - learning_save_answer_missing_session_check: 500 → 404 + проверка владельца (learning.py) - teacher_hardcoded_a1_level: реальный уровень из users вместо 'A1' (teacher.py, 3 места) Security: - hardcoded_default_admin: пустой дефолт ADMIN_IDS (config.py) - double_unquote_initdata: убран повторный unquote (auth.py) - auth_error_leak: обобщённая ошибка вместо str(e) (auth.py) - xforwarded_for_spoof: доверяем только cf-connecting-ip (main.py) - initdata_age_24h: 24ч → 4ч (config.py) Качество: - drop_matview_on_startup: убран DROP при рестарте (main.py) - leaderboard_refresh_30s: 30с → 300с (main.py) - teacher_create_table_on_every_request: TODO на вынос DDL (teacher.py) Аудит: Issue #4, backend 12/20 задач
This commit is contained in:
@@ -589,6 +589,14 @@ async def save_answer(request: Request):
|
||||
|
||||
session = await conn.fetchrow("SELECT * FROM learning_sessions WHERE id = $1", session_id)
|
||||
|
||||
# 🔧 ФИКС (23.09.2026): learning_save_answer_missing_session_check —
|
||||
# раньше при несуществующем session_id падало с TypeError → 500.
|
||||
# Теперь честная 404 + проверка владельца сессии.
|
||||
if not session:
|
||||
raise HTTPException(404, "Session not found")
|
||||
if session["user_id"] != telegram_id:
|
||||
raise HTTPException(403, "Session belongs to another user")
|
||||
|
||||
await conn.execute("""
|
||||
INSERT INTO user_learning_answers (user_id, session_id, level_code, topic_id, lesson_id, question_id, selected_answer, correct, skill_tag, question_type, context_type, difficulty, time_taken_ms, hint_used, wrong_because, is_final_answer)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
|
||||
|
||||
Reference in New Issue
Block a user