Skip to content

fix: guard startSyncFolderOperation against a null folder (#4738) - #4986

Open
ibrahim-iqbal wants to merge 1 commit into
owncloud:masterfrom
ibrahim-iqbal:fix/npe-receive-external-files-4738
Open

ibrahim-iqbal wants to merge 1 commit into
owncloud:masterfrom
ibrahim-iqbal:fix/npe-receive-external-files-4738

Conversation

@ibrahim-iqbal

Copy link
Copy Markdown

Related Issues

App: closes #4738

ReceiveExternalFilesViewModel.refreshFolderUseCase(folderToSync: OCFile) is a Kotlin function with a non-null parameter. ReceiveExternalFilesActivity.startSyncFolderOperation forwarded whatever came in without a null check, so the two entry points that can hand back a null folder crashed with the Kotlin platform-type NPE reported in issue #4738:

  • onSavedCertificate()startSyncFolderOperation(getCurrentDir()), and FileActivity.getCurrentDir() returns null when getFile() is null, when the current file isn't a folder and the storage manager is missing, or when the storage manager can't resolve the parent path (FileActivity.java:455-466).
  • The Play console stack in the issue matches this exact bridge — refreshFolderUseCase (Unknown Source:6) is the Kotlin null check on the parameter.

Changes

  • ReceiveExternalFilesActivity.startSyncFolderOperation: short-circuit and log via Timber when folder is null instead of forwarding to Kotlin.

  • Kept every other caller unchanged — onBackPressed (line 471), onItemClick (line 500), and the initial spaces-root call (line 259) already null-check the folder they pass in, so no other site needed the guard.

  • Changelog file at changelog/unreleased/4738 (Bugfix: type).

  • Release Notes in ReleaseNotesViewModel.kt — crash-only, not a user-visible feature; happy to add one if you'd prefer.


QA

  • Local:
    • ./gradlew :owncloudApp:compileOriginalDebugJavaWithJavac → BUILD SUCCESSFUL.
    • No other callers of startSyncFolderOperation had to change; grep confirms four call sites and the three that aren't getCurrentDir() already guard the value.
  • Manual repro (attach a file into the app, navigate through folders, dismiss a certificate dialog, then rotate/back) is worth running once during review since the crash is timing-dependent, but the null path is now impossible to reach past the guard.

)

`ReceiveExternalFilesViewModel.refreshFolderUseCase(folderToSync: OCFile)`
is a Kotlin function with a non-null parameter. `ReceiveExternalFilesActivity`
was passing the result of `getCurrentDir()` — which returns null whenever
the storage manager cannot resolve the current folder — straight through
without a null check, so the Kotlin platform-type check tripped the NPE
that shows up in the Play console stack in issue owncloud#4738.

Short-circuit `startSyncFolderOperation` when the folder is null and log
the skip via Timber. All other callers already null-check the folder they
pass in; the crash path was the `getCurrentDir()` handoff.

Signed-off-by: ibrahim-iqbal <ibrahim-iqbal@users.noreply.github.com>
@ibrahim-iqbal
ibrahim-iqbal requested a review from a team as a code owner September 21, 2026 07:34
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.

[BUG] Play console crash: NPE refreshFolderUseCase

1 participant