Skip to content

fix: activation failing for users with no demographics row - #149

Open
snehar-nd wants to merge 1 commit into
release-3.8.4from
sn/3.8.4-fix-user-activation
Open

fix: activation failing for users with no demographics row#149
snehar-nd wants to merge 1 commit into
release-3.8.4from
sn/3.8.4-fix-user-activation

Conversation

@snehar-nd

Copy link
Copy Markdown
Contributor

Problem

Clicking Activate on a deactivated user does nothing — the user stays deactivated.

deletedUserDetails (the endpoint the Activate button calls) dereferences the m_userdemographics lookup with no null check:

M_UserDemographics getdemographicsData = employeeMasterInter.DataByUserID(employeeMaster.getUserID());
getdemographicsData.setDeleted(demographics.getDeleted());   // NPE when null

v_showuser — the view backing the employee list — LEFT JOINs m_userdemographics, so a user can legitimately appear in the list with no demographics row. For those users DataByUserID() returns null and the next line throws. The catch turns it into response.setError(e), which is HTTP 200 with statusCode: 5000, so the caller sees no HTTP error and nothing is written.

Fix

  • Skip the demographics update (with a logger.warn) when the row is absent, instead of failing the whole call. m_user.Deleted is what v_showuser exposes as Deleted, so that write alone is what the list reflects — activation now takes effect.
  • Guard the null user row from editData().
  • Guard the Boolean unboxing of getDeleted() in the agent-status branch, which NPEs if the payload omits the flag.
  • Fall back to editedData for the response body when there's no demographics row (it was saveDemoData.toString(), itself a latent NPE).

Scope

Only deletedUserDetails. No change to the success path for users that do have a demographics row: same two writes, same order, same response shape.

Verification status

⚠️ Not compiled or run — no Maven or JDK available in the environment this was written in. The change is small and local, but please build before merging.

The NPE is the strongest candidate and matches every observed symptom, but it has not been confirmed against a live failure — the swallowed error (see the companion UI PR) is precisely what prevents seeing the real exception. To confirm: grep "deletedUserDetails failed with exception" in the Admin-API log after a failed Activate click. If it names something other than an NPE on demographics, this PR still fixes a real latent bug but may not be the whole story.

Related

  • Companion: PSMRI/Admin-UI sn/3.8.4-fix-user-activation — makes the failure visible instead of reporting "Activated successfully". Independent; merge order doesn't matter.
  • Not related to deleteUserRoleMapping / the ASHA reactivation fix on fix/asha-reactivation-facility-check, which is a different endpoint.

🤖 Generated with Claude Code

deletedUserDetails dereferenced the m_userdemographics lookup without a
null check. v_showuser -- which backs the employee list -- LEFT JOINs
m_userdemographics, so a user can legitimately appear in the list with
no demographics row; for those users DataByUserID() returns null and the
next line NPEs. The exception is caught and returned as HTTP 200 with
statusCode 5000, so nothing is written and nothing visibly fails.

The demographics update is now skipped (and logged) when the row is
absent rather than failing the whole call, so activation applies to
m_user as it should. m_user.Deleted is what v_showuser exposes as
Deleted, so that write alone is what the list reflects.

Also guards the two other unchecked dereferences on this path: a null
user row from editData(), and the Boolean unboxing of getDeleted() in
the agent-status branch, which NPEs if the payload omits the flag.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 93834892-611d-426a-b2a5-402e81b2fc87

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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