fix: don't crash import when backup has no filters/tasks/triggers array#409
Open
7MS8 wants to merge 1 commit into
Open
fix: don't crash import when backup has no filters/tasks/triggers array#4097MS8 wants to merge 1 commit into
7MS8 wants to merge 1 commit into
Conversation
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>
8 tasks
|
@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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #406 per reviewer request (separate unrelated fixes into their own PRs).
Bug
Importer.createFilterList()(and the equivalent task/trigger readers) callreader.getJSONArray("filters"), which throwsJSONExceptionwhen the key is absent from the JSON. Backups exported by older app versions don't contain afiltersarray (it was added later), so importing such a backup throws partway throughImporter.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()withoptJSONArray()forfilters,tasks, andtrigger, 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
filterskey (e.g. any backup made before filters were added, or a hand-edited JSON with that key removed).JSONExceptioninsidecreateFilterList(), the whole import aborts — remotes/rclone.conf get written but tasks and other settings are silently never imported.Test plan
./gradlew :app:compileOssDebugSources).filterskey and confirm tasks/preferences now import correctly.