capacitor-community / capacitor-community/intune
NullPointerException in `deRegisterAndUnenrollAccount` when `mUserAccount` is null
- Dominant language
- HTML
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
A `NullPointerException` occurs in `IntunePlugin.java` at line 175 when calling `deRegisterAndUnenrollAccount()` if `mUserAccount` is `null`.
```
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.getcapacitor.community.intune.AppAccount.getAADID()' on a null object reference
at com.getcapacitor.community.intune.IntunePlugin.lambda$deRegisterAndUnenrollAccount$2(IntunePlugin.java:175)
at com.getcapacitor.community.intune.IntunePlugin$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
at java.lang.Thread.run(Thread.java:1119)
```
**To Reproduce**
1. Install app without logging in, OR
2. Update app from a version that didn't use MAM Intune, OR
3. Logout and then call the method again
Then call:
```typescript
await IntuneMAM.deRegisterAndUnenrollAccount({ accountId: '' });
```
The app will crash with NPE.
**Expected behavior**
The similar method `logoutOfAccount` (line 197-219) correctly handles this case with a null check.
**Smartphone:**
- Plugin version: 8.0.0
- Capacitor version: 7.0.0
- Platform: Android
Contributor guide
Research direction
Start in IntunePlugin.java at line 175 and compare deRegisterAndUnenrollAccount with logoutOfAccount at lines 197-219. Reproduce the call with an empty accountId after mUserAccount is null, then verify the method completes without the reported NullPointerException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100