Skip to content

Return MISSING_DATA instead of INCORRECT_OTP when no OTP is sent - #314

Merged
OrangeAndGreen merged 4 commits into
mainfrom
dv/confirm-otp-param
Oct 15, 2026
Merged

OrangeAndGreen merged 4 commits into
mainfrom
dv/confirm-otp-param

Conversation

@OrangeAndGreen

@OrangeAndGreen OrangeAndGreen commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Technical Summary

When no code was sent, confirm_otp and confirm_session_otp checked the code against None. The response was 401 INCORRECT_OTP, and it used up one of the user's tries. That hid a different problem behind a "wrong code" error: the client hadn't sent the field the endpoint reads (token for confirm_otp, otp for confirm_session_otp).

  • Both endpoints now return 400 MISSING_DATA when no code is sent. The request doesn't count as a failed attempt.

Logging and monitoring

None needed.

Safety Assurance

Safety story

Requests that include a code behave the same as before. A request with no code now gets 400 MISSING_DATA instead of 401 INCORRECT_OTP. Before this change, that request could never succeed.

  • I am confident that this change will not break current and/or previous versions of CommCare apps

Automated test coverage

  • TestConfirmOTP::test_missing_token and TestConfirmSessionOtp::test_missing_otp: a missing code returns MISSING_DATA and doesn't count as a failed attempt.
  • TestConfirmOTP::test_correct_code_validates_phone: a real code that was sent validates the phone, with no mocks on verification.
  • Full suite passes (571 tests).

QA Plan

Send confirm_otp with no token. It should return 400 MISSING_DATA and leave the attempt count unchanged.

Deployment

  • This PR can be deployed: any required configuration, commands, or other manual steps required before this PR can be deployed are done.

Labels & Review

  • The set of people pinged as reviewers is appropriate for the level of risk of the change

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7dad7855-cdd4-4498-8832-e40454af5561
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@OrangeAndGreen OrangeAndGreen self-assigned this Oct 2, 2026
confirm_otp and confirm_session_otp verified a missing code against None,
which came back as 401 INCORRECT_OTP and spent one of the user's attempts.
Both now return 400 MISSING_DATA when no code is sent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@OrangeAndGreen OrangeAndGreen changed the title Accept otp in confirm_otp and reject a missing code as MISSING_DATA Return MISSING_DATA instead of INCORRECT_OTP when no OTP is sent Oct 2, 2026
@OrangeAndGreen
OrangeAndGreen merged commit ea403db into main Oct 15, 2026
8 checks passed
@OrangeAndGreen
OrangeAndGreen deleted the dv/confirm-otp-param branch October 15, 2026 15:59
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.

2 participants