Skip to content

fix: don't crash import when backup has no filters/tasks/triggers array#409

Open
7MS8 wants to merge 1 commit into
newhinton:masterfrom
7MS8:fix/import-missing-arrays
Open

fix: don't crash import when backup has no filters/tasks/triggers array#409
7MS8 wants to merge 1 commit into
newhinton:masterfrom
7MS8:fix/import-missing-arrays

Conversation

@7MS8

@7MS8 7MS8 commented Jul 8, 2026

Copy link
Copy Markdown

Split out of #406 per reviewer request (separate unrelated fixes into their own PRs).

Bug

Importer.createFilterList() (and the equivalent task/trigger readers) call reader.getJSONArray("filters"), which throws JSONException when the key is absent from the JSON. Backups exported by older app versions don't contain a filters array (it was added later), so importing such a backup throws partway through Importer.importJson() and aborts the entire import — remotes get written, but tasks/preferences never do. This matches the symptom reported in review of #406 ("remotes populated but no tasks imported"), which the reviewer confirmed as reproducible.

Fix

Replace getJSONArray() with optJSONArray() for filters, tasks, and trigger, returning an empty list when the key is missing, so a backup missing a newer field still imports the sections that are present instead of aborting entirely.

Reproduction

  • Take (or construct) a backup export JSON that has no top-level filters key (e.g. any backup made before filters were added, or a hand-edited JSON with that key removed).
  • Import it via Settings → Import.
  • Before this fix: import throws a JSONException inside createFilterList(), the whole import aborts — remotes/rclone.conf get written but tasks and other settings are silently never imported.
  • After this fix: import completes for all sections present in the backup.

Test plan

  • Local build compiles (./gradlew :app:compileOssDebugSources).
  • Import a legacy backup JSON without a filters key and confirm tasks/preferences now import correctly.

getJSONArray() throws JSONException when the key is absent. Backups
from older versions only contain the arrays that exist — filters in
particular was added later and is missing from all pre-existing exports.
Replace with optJSONArray() and return an empty list when the key is not
present, so a partial backup still imports the sections that are there.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@scr4bble

Copy link
Copy Markdown

@newhinton I believe this PR is quite useful, and both the issue and the fix are clear and straightforward, so it should require very little testing. Would you have a bit of time to take a look and, if everything seems fine, approve and merge it?

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.

2 participants