Skip to content

Fix login redirection issues#3530

Merged
avazirna merged 3 commits intomasterfrom
fix-login-redirect-crash-from-non-activity-context
Feb 11, 2026
Merged

Fix login redirection issues#3530
avazirna merged 3 commits intomasterfrom
fix-login-redirect-crash-from-non-activity-context

Conversation

@avazirna
Copy link
Copy Markdown
Contributor

@avazirna avazirna commented Feb 5, 2026

Product Description

This PR addresses two issues with the login redirection:

  1. Fixes a RuntimeException when the redirection is triggered from a non-Activity context
  2. Make the session-expiration broadcast package-scoped to ensure the login redirection is reliably received.
  • When the receiver fails, users may be left in restricted areas. After a user action, an exception is thrown due to an invalid evaluation context and its handling causes CommCare to crash because of the issue described in the previous bullet (see video below). The initial exception is captured as a non-fatal: Crashlytics report.
    case_list_crash_after_session_expiration.mp4

Safety Assurance

Safety story

Minor improvements to ensure that the login redirection works as expected and without crashes.

Labels and Review

  • Do we need to enhance the manual QA test coverage ? If yes, the "QA Note" label is set correctly
  • Does the PR introduce any major changes worth communicating ? If yes, the "Release Note" label is set and a "Release Note" is specified in PR description.
  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

This pull request makes two targeted modifications to intent handling. First, the expireUserSession method in CommCareApplication now explicitly targets the USER_SESSION_EXPIRED broadcast to the application's own package using setPackage(). Second, in SessionRegistrationHelper, the login redirect logic is updated to use addFlags() instead of setFlags() and conditionally adds FLAG_ACTIVITY_NEW_TASK when the context is not an Activity instance, ensuring proper task stack management across different context types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • shubham1g5
  • OrangeAndGreen
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description covers product issues, safety story, and labels review, but lacks several template sections like Technical Summary (ticket link/design), Feature Flag, Automated test coverage, and QA Plan details. Add missing sections: provide a ticket/document link, describe design decisions, specify automated test coverage, and detail the QA plan with test conditions.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main changes in the PR, which focus on fixing login redirection issues including crash prevention and broadcast scoping.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-login-redirect-crash-from-non-activity-context

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

@shubham1g5 shubham1g5 left a comment

Choose a reason for hiding this comment

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

Are you also able to add details on the other eval context crash that this fixes and repro around it in context of session expiration.

Comment thread app/src/org/commcare/utils/SessionRegistrationHelper.java
Copy link
Copy Markdown
Contributor

@conroy-ricketts conroy-ricketts left a comment

Choose a reason for hiding this comment

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

LGTM, I also like Shubham's suggestion

@shubham1g5
Copy link
Copy Markdown
Contributor

The initial exception is captured as a non-fatal: Crashlytics report.

Does that mean that there is no other "crash" associated with this PR and only a non-fatal ?

@avazirna
Copy link
Copy Markdown
Contributor Author

The initial exception is captured as a non-fatal: Crashlytics report.

Does that mean that there is no other "crash" associated with this PR and only a non-fatal ?

Yes, there are other crashes caused by "no appropriate evaluation context", but it's hard to tell whether these are a result of the login redirection issues or not, so this change is to rule those out.

@avazirna avazirna merged commit 8ec4ef3 into master Feb 11, 2026
7 checks passed
@avazirna avazirna added this to the 2.61.5 milestone Feb 11, 2026
@avazirna avazirna self-assigned this Feb 11, 2026
@avazirna avazirna deleted the fix-login-redirect-crash-from-non-activity-context branch February 13, 2026 21: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.

3 participants