Skip to content

Feat/subsonic tests - #985

Merged
eddyizm merged 5 commits into
developmentfrom
feat/subsonic-tests
Aug 16, 2026
Merged

Feat/subsonic tests#985
eddyizm merged 5 commits into
developmentfrom
feat/subsonic-tests

Conversation

@eddyizm

@eddyizm eddyizm commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Adding unit tests for #954 that I stashed because they weren't ready.

eddyizm added 4 commits August 2, 2026 11:12
  ## Root Cause

  NullPointerException in Subsonic.java at line 149.

  ### Crash path

    MainActivity.onStart()
      → initService() + fragment restored from saved state
          → PlayerBottomSheetFragment.onCreateView()
              → setHeaderBookmarksButton()          [line 70]
    		  → ViewModel.getPlayQueue()         [line 286]
                      → QueueRepository.getPlayQueue()
                          → App.getSubsonicClientInstance(false)
                              → Subsonic.getParams()
                                  → preferences.getAuthentication().getPassword()  💥 NPE

  ### Why it only started in v4.23.0

  The TransactionTooLargeException fix (PR #863) added MainActivity.onSaveInstanceState logic that preserves or clears fragment back-stack state. On upgrade, Android OS can now restore
  the full fragment stack from the previous session — including PlayerBottomSheetFragment — before the user logs in or their credentials are re-loaded.

  In SubsonicPreferences.java, the authentication field is only set if at least one credential is non-null. If SharedPreferences yields all-null credentials (fresh install scenario,
  corrupted prefs after upgrade), authentication stays null — and the old code called .getPassword() on that null reference without a guard.

  ## The Fix

  In Subsonic.java, getParams() now locally captures getAuthentication() and wraps all credential puts in a single auth != null guard:

    -        if (preferences.getAuthentication().getPassword() != null)
    -            params.put("p", preferences.getAuthentication().getPassword());
    -        if (preferences.getAuthentication().getSalt() != null)
    -            params.put("s", preferences.getAuthentication().getSalt());
    -        if (preferences.getAuthentication().getToken() != null)
    -            params.put("t", preferences.getAuthentication().getToken());
    +        SubsonicPreferences.SubsonicAuthentication auth = preferences.getAuthentication();
    +        if (auth != null) {
    +            if (auth.getPassword() != null)
    +                params.put("p", auth.getPassword());
    +            if (auth.getSalt() != null)
    +                params.put("s", auth.getSalt());
    +            if (auth.getToken() != null)
    +                params.put("t", auth.getToken());
    +        }

  This also avoids calling getAuthentication() 6 times — the result is captured once. When credentials are missing, getPlayQueue() will gracefully return an empty/null response instead
  of crashing the app on startup.
@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1727779f-ad67-4f43-998e-7ae5a13d441b

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.

@eddyizm
eddyizm merged commit fcdf777 into development Aug 16, 2026
1 check passed
@eddyizm
eddyizm deleted the feat/subsonic-tests branch August 16, 2026 16:40
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