Skip to content

CCCT-2355 Retry Start Configuration On Missing Integrity Token#3731

Open
shubham1g5 wants to merge 3 commits into
masterfrom
ccct-2355_integrity_crash
Open

CCCT-2355 Retry Start Configuration On Missing Integrity Token#3731
shubham1g5 wants to merge 3 commits into
masterfrom
ccct-2355_integrity_crash

Conversation

@shubham1g5
Copy link
Copy Markdown
Contributor

@shubham1g5 shubham1g5 commented May 22, 2026

CCCT-2355

Product Description

Fixes a PersonalID configuration crash where the server rejects the start-configuration request because the integrity token was missing from the request headers. The app now fetches a fresh token and retries the request once instead of showing an error screen.

Some Useful notes to review:

  • We make the call to the server without token in the first place as token is not always mandatory depending on whether the user is pre-invited or not.
  • While retrying, we don't make antoher request to server if the token request fails given server has already failed processing the request without token.

Safety Assurance

Safety story

  • I ran the unit tests, which cover all three retry scenarios (see Automated test coverage below).
  • The retry is bounded to a single attempt — no infinite loop risk.
  • Not exercised on a real device — only unit tests, given harnessing the exact scenario is quite cumbersome without mocks. Although I am quite comfortable with the test coverage on this change.

Automated test coverage

Added tests in PersonalIdPhoneFragmentStartConfigurationTest

@shubham1g5 shubham1g5 self-assigned this May 22, 2026
@shubham1g5
Copy link
Copy Markdown
Contributor Author

shubham1g5 commented May 22, 2026

Suggested Review Order

Review commit by commit

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR improves integrity token handling and error recovery in the personal ID configuration flow. The API handler now unconditionally records error subcodes before switch evaluation, making them available for all error types. The fragment introduces fetchIntegrityTokenAndStartConfiguration() and retryWithNewIntegrityToken() helpers to acquire tokens and auto-retry configuration when integrity headers are missing. Error handling is refactored so INTEGRITY_ERROR routes to a centralized handler and MISSING_DATA_ERROR conditionally retries. Three new tests validate the retry behavior under different token and failure states.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.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 clearly summarizes the main change: implementing a retry mechanism for start configuration when integrity token is missing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description includes all key sections: product impact, technical context with ticket link, safety assurance with testing details, and rationale for design decisions.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ccct-2355_integrity_crash

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
Contributor

@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)
app/unit-tests/src/org/commcare/fragments/personalId/PersonalIdPhoneFragmentStartConfigurationTest.kt (1)

44-44: 💤 Low value

Reminder: Run ktlint after changes.

As per coding guidelines, run ./gradlew ktlintFile -PfilePath=app/unit-tests/src/org/commcare/fragments/personalId/PersonalIdPhoneFragmentStartConfigurationTest.kt to verify formatting.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@app/unit-tests/src/org/commcare/fragments/personalId/PersonalIdPhoneFragmentStartConfigurationTest.kt`
at line 44, The test file contains formatting/ktlint issues for the class
PersonalIdPhoneFragmentStartConfigurationTest; run the ktlint fixer against this
file and apply the suggested formatting changes by executing the project ktlint
task for that file (e.g., use ./gradlew ktlintFile -PfilePath=<this test file>)
and commit the updated formatting so the class
PersonalIdPhoneFragmentStartConfigurationTest conforms to project style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@app/unit-tests/src/org/commcare/fragments/personalId/PersonalIdPhoneFragmentStartConfigurationTest.kt`:
- Around line 286-310: The new test
testStartConfiguration_missingDataIntegrityHeaders_noToken_retriesAndSucceeds
lacks the QA automation guard, so it will fail when biometric navigation is
skipped in QA runs; add an assumeFalse(BuildConfig.IS_QA_AUTOMATION) at the
start of this test (same approach used in
testStartConfiguration_successResponse_moveToBiometric) so the test is skipped
in QA automation builds and only asserts navigation in normal runs.

---

Nitpick comments:
In
`@app/unit-tests/src/org/commcare/fragments/personalId/PersonalIdPhoneFragmentStartConfigurationTest.kt`:
- Line 44: The test file contains formatting/ktlint issues for the class
PersonalIdPhoneFragmentStartConfigurationTest; run the ktlint fixer against this
file and apply the suggested formatting changes by executing the project ktlint
task for that file (e.g., use ./gradlew ktlintFile -PfilePath=<this test file>)
and commit the updated formatting so the class
PersonalIdPhoneFragmentStartConfigurationTest conforms to project style.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ec6b9f06-3912-49d8-b13e-f26552193040

📥 Commits

Reviewing files that changed from the base of the PR and between 3d86f7b and 4737fdc.

📒 Files selected for processing (3)
  • app/src/org/commcare/connect/network/connectId/PersonalIdApiHandler.java
  • app/src/org/commcare/fragments/personalId/PersonalIdPhoneFragment.java
  • app/unit-tests/src/org/commcare/fragments/personalId/PersonalIdPhoneFragmentStartConfigurationTest.kt

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 23.36%. Comparing base (eb409cf) to head (4737fdc).
⚠️ Report is 46 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3731      +/-   ##
============================================
+ Coverage     23.31%   23.36%   +0.05%     
- Complexity     3929     3938       +9     
============================================
  Files           924      924              
  Lines         56190    56210      +20     
  Branches       6654     6656       +2     
============================================
+ Hits          13098    13134      +36     
+ Misses        41394    41376      -18     
- Partials       1698     1700       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@shubham1g5 shubham1g5 marked this pull request as ready for review May 22, 2026 11:03
@shubham1g5 shubham1g5 added the skip-integration-tests Skip android tests. label May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-integration-tests Skip android tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants