{"record":{"id":"4663c1dd037007c8","repo":"MuntashirAkon/AppManager","slug":"failed-to-decrypt-miscfile-getname","errorCode":null,"errorMessage":"Failed to decrypt ${miscFile.getName()}","messagePattern":"Failed to decrypt (.+?)","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java","lineNumber":743,"sourceCode":"            miscFile = mBackupItem.getMiscFile();\n        } catch (IOException e) {\n            // There are no permissions, just skip\n            return;\n        }\n        if (!mRequestedFlags.skipSignatureCheck()) {\n            String checksum = DigestUtils.getHexDigest(mBackupInfo.checksumAlgo, miscFile);\n            if (!checksum.equals(mChecksum.get(miscFile.getName()))) {\n                throw new BackupException(\"Couldn't verify misc file.\" +\n                        \"\\nFile: \" + miscFile +\n                        \"\\nFound: \" + checksum +\n                        \"\\nRequired: \" + mChecksum.get(miscFile.getName()));\n            }\n        }\n        // Decrypt permission file\n        try {\n            miscFile = mBackupItem.decrypt(new Path[]{miscFile})[0];\n        } catch (IOException | IndexOutOfBoundsException e) {\n            throw new BackupException(\"Failed to decrypt \" + miscFile.getName(), e);\n        }\n        try {\n            rules.loadExternalEntries(miscFile);\n        } catch (Throwable e) {\n            throw new BackupException(\"Failed to load rules from misc.\", e);\n        }\n    }\n\n    private void restoreRules() throws BackupException {\n        // Apply rules\n        if (!mIsInstalled) {\n            throw new BackupException(\"Rules restore is requested but the app isn't installed.\");\n        }\n        Path rulesFile;\n        try {\n            rulesFile = mBackupItem.getRulesFile();\n        } catch (IOException e) {\n            if (mBackupMetadata.hasRules) {","sourceCodeStart":725,"sourceCodeEnd":761,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java#L725-L761","documentation":"Thrown by loadMiscRules when decrypting the misc (permissions) file via mBackupItem.decrypt throws IOException or IndexOutOfBoundsException. It indicates the encrypted misc file could not be decrypted into a usable Path, usually because of a wrong password, missing crypto material, or an empty/absent result array.","triggerScenarios":"mBackupItem.decrypt(new Path[]{miscFile}) throws IOException (bad password, corrupt file, I/O failure) or IndexOutOfBoundsException (decrypt returned an empty array — no decrypted output produced).","commonSituations":"Wrong decryption password for an encrypted backup; the misc file was not fully copied or is zero bytes; encryption keys absent from the backup; the backup is unencrypted but the decrypt path was still invoked with no matching key.","solutions":["Provide the correct encryption password for the backup","Check the misc file exists, is non-empty, and matches its recorded size/checksum","Ensure the backup's crypto/key files were copied along with the misc file","Re-create the backup with encryption enabled and verified if the file is corrupt"],"exampleFix":"// before\nmiscFile = mBackupItem.decrypt(new Path[]{miscFile})[0]; // raw call, same failure\n// after\nPath[] decrypted = mBackupItem.decrypt(new Path[]{miscFile});\nif (decrypted == null || decrypted.length == 0) {\n    Log.e(TAG, \"Decryption produced no output for \" + miscFile.getName());\n    return;\n}\nmiscFile = decrypted[0];","handlingStrategy":"try-catch","validationCode":"if (!miscFile.exists() || miscFile.size() == 0) {\n    throw new IllegalStateException(\"Misc file missing or empty — decryption will fail\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    restoreOp.runRestore();\n} catch (BackupException e) {\n    if (e.getMessage().startsWith(\"Failed to decrypt\")) {\n        rePromptForPassword(\"Misc file decryption failed\");\n    } else throw e;\n}","preventionTips":["Verify backup completeness (all files + keys) before restoring","Confirm password correctness for the whole restore run","Skip misc restore if the misc file is absent","Validate checksums before decrypting"],"tags":["android","backup","encryption","decryption","misc"],"backgroundTag":"checksum-mismatch","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"}