Skip to content

fix: show better error message when incorrect otp is entered#29

Open
harshp4114 wants to merge 4 commits intoresilient-tech:version-15from
harshp4114:handling-incorrect-otp
Open

fix: show better error message when incorrect otp is entered#29
harshp4114 wants to merge 4 commits intoresilient-tech:version-15from
harshp4114:handling-incorrect-otp

Conversation

@harshp4114
Copy link
Copy Markdown
Member

@harshp4114 harshp4114 commented Mar 16, 2026

Closes: #24

@harshp4114 harshp4114 marked this pull request as ready for review March 19, 2026 12:26
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bbc24e62-b792-4d80-9fdd-42b29f098144

📥 Commits

Reviewing files that changed from the base of the PR and between 3cfe6ec and 924ccc0.

📒 Files selected for processing (1)
  • bank_integration/bank_integration/api/hdfc_bank_api.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • bank_integration/bank_integration/api/hdfc_bank_api.py

📝 Walkthrough

Walkthrough

The pull request updates the HDFC Bank API integration. process_otp reformats a get_element("channel-BOTH", "id", now=True) call to multiple lines with no behavior change. submit_otp adds XPath/CSS-based detection after clicking Submit and waits up to 5 seconds for either incorrect/invalid OTP indicators or success; if incorrect/invalid OTP is detected it raises specific restart-the-payment errors. make_payment reformats a throw() call across multiple lines. No public signatures changed. Lines changed: +33 / -2.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: improved error messaging when an incorrect OTP is entered in the payment flow.
Description check ✅ Passed The description references linked issue #24, which is related to OTP handling, matching the changeset scope.
Linked Issues check ✅ Passed The code changes implement better error handling and user-facing messages for incorrect OTP scenarios, directly addressing issue #24's requirements.
Out of Scope Changes check ✅ Passed All changes are scoped to OTP error handling in the HDFC bank API; minor reformatting of existing calls remains within scope of improving OTP error messaging.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
bank_integration/bank_integration/api/hdfc_bank_api.py (1)

297-304: Simplify the redundant condition.

The condition (found and found[-1] == X) or (found and found[-1] == Y) can be simplified since both branches check found first.

♻️ Proposed simplification
-            if (
-                (found and found[-1] == invalid_otp_length_xpath)
-                or (found and found[-1] == incorrect_otp_xpath)
-            ):  
-
+            if found and found[-1] in (invalid_otp_length_xpath, incorrect_otp_xpath):
                 self.throw(
                     "You have entered an incorrect otp. Please start the payment process again"
                 )

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 183f1ba7-9fbe-4999-86ce-db23e050fa81

📥 Commits

Reviewing files that changed from the base of the PR and between f5477d2 and 43b55f2.

📒 Files selected for processing (1)
  • bank_integration/bank_integration/api/hdfc_bank_api.py

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Mar 19, 2026

Confidence Score: 4/5

  • This PR is safe to merge — the logic is correct, follows established codebase patterns, and addresses all previously raised concerns.
  • The implementation is consistent with how _found_element and AnyEC are used throughout the file, the XPath expressions use contains() for robustness, success conditions are included to avoid blocking on correct OTPs, and error messages are now distinct and actionable. The only issue found is a trivial missing space in a CSS tuple.
  • No files require special attention.

Important Files Changed

Filename Overview
bank_integration/bank_integration/api/hdfc_bank_api.py Adds OTP error detection after submission — waits up to 5 s for error/success signals, then throws distinct messages for incorrect OTP vs. wrong OTP length. Logic is consistent with the rest of the codebase (_found_element[-1] pattern, AnyEC, throw="ignore"). Minor style nit: missing space in the CSS_SELECTOR tuple.

Reviews (4): Last reviewed commit: "fix: resolve comments" | Re-trigger Greptile

@harshp4114
Copy link
Copy Markdown
Member Author

@greptileai

1 similar comment
@harshp4114
Copy link
Copy Markdown
Member Author

@greptileai

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
bank_integration/bank_integration/api/hdfc_bank_api.py (1)

302-302: Minor: Inconsistent casing of "OTP" in error message.

The error message uses lowercase "otp" while the standard abbreviation is "OTP" (as used in line 298).

✏️ Suggested fix
                 elif found[-1] == incorrect_otp_xpath:
                     self.throw(
-                        "You have entered an incorrect otp. Please start the payment process again"
+                        "You have entered an incorrect OTP. Please start the payment process again."
                     )

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 02fb30c8-aa75-4c11-90f1-e188f95c13e4

📥 Commits

Reviewing files that changed from the base of the PR and between 6021581 and 3cfe6ec.

📒 Files selected for processing (1)
  • bank_integration/bank_integration/api/hdfc_bank_api.py

@harshp4114
Copy link
Copy Markdown
Member Author

@greptileai

re-evaluate the whole pr and then just update the confidence score. also take in consideration that some changes are done in other pr's. Also regarding the xpath fragility of incorrect_otp_xpath, the element has only 2 things that can be used in the xpath that is class='text-danger' and the text 'You have entered incorrect OTP.'. so don't include that as a bug.

@harshp4114
Copy link
Copy Markdown
Member Author

@greptileai

re-evaluate the whole pr and then just update the confidence score. also take in consideration that some changes are done in other pr's. Also regarding the xpath fragility of incorrect_otp_xpath, the element has only 2 things that can be used in the xpath that is class='text-danger' and the text 'You have entered incorrect OTP.'. so don't include that as a bug.

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.

incorrect OTP handling

1 participant