{"record":{"id":"26c4190112ea8834","repo":"MuntashirAkon/AppManager","slug":"could-not-read-backup-info-possibly-due-to-a-malformed-json-26c419","errorCode":null,"errorMessage":"Could not read backup info. Possibly due to a malformed json file.","messagePattern":"Could not read backup info\\. Possibly due to a malformed json file\\.","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/VerifyOp.java","lineNumber":39,"sourceCode":"    @NonNull\n    private final BackupFlags mBackupFlags;\n    @NonNull\n    private final BackupMetadataV5.Info mBackupInfo;\n    @NonNull\n    private final BackupMetadataV5.Metadata mBackupMetadata;\n    @NonNull\n    private final BackupItems.BackupItem mBackupItem;\n    @NonNull\n    private final BackupItems.Checksum mChecksum;\n\n    VerifyOp(@NonNull BackupItems.BackupItem backupItem) throws BackupException {\n        mBackupItem = backupItem;\n        try {\n            mBackupInfo = mBackupItem.getInfo();\n            mBackupFlags = mBackupInfo.flags;\n        } catch (IOException e) {\n            mBackupItem.cleanup();\n            throw new BackupException(\"Could not read backup info. Possibly due to a malformed json file.\", e);\n        }\n        // Setup crypto\n        if (!CryptoUtils.isAvailable(mBackupInfo.crypto)) {\n            mBackupItem.cleanup();\n            throw new BackupException(\"Mode \" + mBackupInfo.crypto + \" is currently unavailable.\");\n        }\n        try {\n            mBackupItem.setCrypto(mBackupInfo.getCrypto());\n        } catch (CryptoException e) {\n            mBackupItem.cleanup();\n            throw new BackupException(\"Could not get crypto \" + mBackupInfo.crypto, e);\n        }\n        try {\n            mBackupMetadata = mBackupItem.getMetadata(mBackupInfo).metadata;\n        } catch (IOException e) {\n            mBackupItem.cleanup();\n            throw new BackupException(\"Could not read backup metadata. Possibly due to a malformed json file.\", e);\n        }","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/VerifyOp.java#L21-L57","documentation":"The VerifyOp constructor calls mBackupItem.getInfo() to parse backup.json. If reading or JSON-parsing that file throws an IOException, cleanup() runs and this BackupException is thrown. It means the backup descriptor file is missing, unreadable, or not valid JSON.","triggerScenarios":"Constructing VerifyOp (or running verify) on a backup directory where backup.json is absent, truncated, or contains malformed JSON — typically after an interrupted backup or a partial copy.","commonSituations":"Backing up to SD card/cloud that dropped files during transfer, manually edited backup.json with a syntax error, restoring only part of a backup directory, or file-permission issues making backup.json unreadable.","solutions":["Validate backup.json with a JSON parser/validator and fix syntax errors if it was hand-edited.","Re-copy the complete backup directory from the source device, including backup.json.","Recreate the backup on the source device if the original file is truncated.","Check file permissions/readability of backup.json for the AppManager process."],"exampleFix":"// before: backup.json with trailing comma\n{\"flags\": \"...\",}\n// after: valid JSON\n{\"flags\": \"...\"}","handlingStrategy":"validation","validationCode":"// Validate backup.json parses before constructing VerifyOp\nFile f = new File(backupDir, \"backup.json\");\nif (!f.isFile() || f.length() == 0) throw new IllegalStateException(\"backup.json missing/empty\");\ntry (FileInputStream in = new FileInputStream(f)) {\n    new JSONObject(new String(IOUtils.readFully(in))); // throws if malformed\n}","typeGuard":null,"tryCatchPattern":"try {\n    new VerifyOp(backupItem).verify();\n} catch (BackupException e) {\n    if (e.getMessage().contains(\"malformed json\")) {\n        // re-copy or regenerate the backup\n    }\n}","preventionTips":["Copy entire backup directories, never individual files.","Never hand-edit backup.json; regenerate via the app instead.","Sanity-check a freshly copied backup by parsing backup.json before deleting the original."],"tags":["json","backup-info","malformed-file","backup-restore"],"backgroundTag":"json-parse-error","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}