Skip to content

fix(captcha): guard against duplicate callback delivery race#19

Merged
rezhajulio merged 1 commit into
mainfrom
fix/captcha-callback-race
Jul 4, 2026
Merged

fix(captcha): guard against duplicate callback delivery race#19
rezhajulio merged 1 commit into
mainfrom
fix/captcha-callback-race

Conversation

@rezhajulio

Copy link
Copy Markdown
Owner

Summary

  • Fixes a race from feat: integrate profile completeness check into captcha verification #9 where two concurrent deliveries of the same captcha verify callback (double-tap) could both pass the profile check and both run unrestrict_user + start_new_user_probation before either cancelled the timeout job.
  • remove_pending_captcha's existing delete-rowcount return value now gates finalization: only the delivery that actually removes the row proceeds; the duplicate acks quietly and exits.
  • Drops trailing whitespace in user_checker.py.
  • Ignores local .tokensave/ cache directory.

Test plan

  • uv run pytest — 987 passed
  • uv run ruff check . — clean
  • uv run mypy src/bot/ tests/ — clean
  • 100% coverage on captcha.py and user_checker.py
  • New test test_duplicate_callback_delivery_ignored covers the race guard

Double-tapping the verify button raced two callback deliveries through
check_user_profile before either delivery removed the pending captcha
row, risking a double unrestrict_user + start_new_user_probation call.
remove_pending_captcha's existing delete-rowcount now gates finalization
so only the delivery that actually removes the row proceeds.

Also cleans trailing whitespace in user_checker.py and ignores the
local .tokensave/ cache directory.
@rezhajulio rezhajulio merged commit 382c6da into main Jul 4, 2026
5 checks passed
@rezhajulio rezhajulio deleted the fix/captcha-callback-race branch July 4, 2026 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant