{"record":{"id":"dfe4bfa8a41538de","repo":"MuntashirAkon/AppManager","slug":"empty-json-string-for-path","errorCode":null,"errorMessage":"Empty JSON string for path ","messagePattern":"Empty JSON string for path ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/MetadataManager.java","lineNumber":55,"sourceCode":"\n    @VisibleForTesting\n    public static void setCurrentBackupMetaVersion(int version) {\n        currentBackupMetaVersion = version;\n    }\n\n    public static int getCurrentBackupMetaVersion() {\n        return currentBackupMetaVersion;\n    }\n\n    @NonNull\n    @WorkerThread\n    public static BackupMetadataV5.Info readInfo(@NonNull BackupItems.BackupItem backupItem) throws IOException {\n        boolean v5AndUp = backupItem.isV5AndUp();\n        Path infoFile = v5AndUp ? backupItem.getInfoFile() : backupItem.getMetadataV2File();\n        String infoString = infoFile.getContentAsString();\n        JSONObject jsonObject;\n        if (TextUtils.isEmpty(infoString)) {\n            throw new IOException(\"Empty JSON string for path \" + infoFile);\n        }\n        try {\n            jsonObject = new JSONObject(infoString);\n            BackupMetadataV5.Info info = new BackupMetadataV5.Info(jsonObject);\n            info.setBackupItem(backupItem);\n            return info;\n        } catch (JSONException e) {\n            throw new IOException(e.getMessage() + \" for path \" + infoFile, e);\n        }\n    }\n\n    @NonNull\n    @WorkerThread\n    public static BackupMetadataV5 readMetadata(@NonNull BackupItems.BackupItem backupItem) throws IOException {\n        BackupMetadataV5.Info info = readInfo(backupItem);\n        return readMetadata(backupItem, info);\n    }\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/MetadataManager.java#L37-L73","documentation":"readInfo parses the backup's info file (info.am.json for v5+, meta_v2.am.json otherwise). It throws IOException when the file content string is empty because a valid JSON info document is mandatory to identify and decrypt a backup.","triggerScenarios":"Calling readInfo (directly or via info) on a BackupItem whose info/metadata file is missing, zero-byte, or failed to decrypt to readable text.","commonSituations":"Corrupted or truncated backup archives (interrupted transfer), backups created by old versions with different file names, or selecting the wrong directory so the expected info file doesn't exist and content comes back empty.","solutions":["Verify the backup directory contains info.am.json (v5+) or meta_v2.am.json and that it is non-empty before reading.","Re-copy/redownload the backup archive — the file is likely truncated or corrupted.","If decryption is configured, ensure the crypto settings are correct so content decrypts to valid text."],"exampleFix":"// before\nBackupMetadataV5.Info info = MetadataManager.readInfo(backupItem);\n// after\nif (!backupItem.getInfoFile().exists() || TextUtils.isEmpty(backupItem.getInfoFile().getContentAsString())) {\n    throw new IOException(\"Backup info file missing or empty: \" + backupItem.getBackupName());\n}\nBackupMetadataV5.Info info = MetadataManager.readInfo(backupItem);","handlingStrategy":"try-catch","validationCode":"Path infoFile = backupItem.isV5AndUp() ? backupItem.getInfoFile() : backupItem.getMetadataV2File();\nString s = infoFile.getContentAsString();\nif (TextUtils.isEmpty(s)) throw new IOException(\"Missing/empty info file: \" + infoFile);","typeGuard":null,"tryCatchPattern":"try {\n    BackupMetadataV5.Info info = MetadataManager.readInfo(backupItem);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"Empty JSON string\")) {\n        // flag backup as corrupted/incomplete and surface to the user\n    } else throw e;\n}","preventionTips":["Verify backup archive integrity (checksums) right after creation or transfer.","Never hand-delete metadata files from backup directories.","Confirm decryption settings before reading backups."],"tags":["backup","json","io","empty-file"],"backgroundTag":"empty-required-field","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}