{"record":{"id":"881c42df4cbb4115","repo":"MuntashirAkon/AppManager","slug":"failed-to-load-rules-from-misc","errorCode":null,"errorMessage":"Failed to load rules from misc.","messagePattern":"Failed to load rules from misc\\.","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java","lineNumber":748,"sourceCode":"        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) {\n                throw new BackupException(\"Rules file is missing.\", e);\n            } else {\n                // There are no rules, just skip\n                return;\n            }","sourceCodeStart":730,"sourceCodeEnd":766,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java#L730-L766","documentation":"Thrown by loadMiscRules when rules.loadExternalEntries(miscFile) throws any Throwable while parsing the decrypted misc file into PseudoRules entries. The decryption succeeded, but the file's content could not be interpreted as valid misc rules.","triggerScenarios":"loadExternalEntries throws during parsing — e.g. malformed/unrecognized format in the decrypted misc file, version mismatch between the backup's misc format and the current AppManager parser, or a read error mid-parse.","commonSituations":"Restoring a backup produced by an older/newer AppManager with a changed misc format; the decrypted file is garbage because decryption silently used the wrong parameters; hand-crafted misc files.","solutions":["Update AppManager to a version compatible with the backup's format (or use the version that created the backup)","Inspect the decrypted misc file to confirm it parses as expected permissions data","Regenerate the backup from a working device so the misc file is written in the current format","If the misc data is unimportant, disable misc restore and continue with data restore"],"exampleFix":"// before\nrules.loadExternalEntries(miscFile);\n// after\ntry {\n    rules.loadExternalEntries(miscFile);\n} catch (Throwable e) {\n    Log.w(TAG, \"Misc rules unparseable; skipping misc restore\", e);\n}","handlingStrategy":"try-catch","validationCode":"try (InputStream in = miscFile.openInputStream()) {\n    if (in.read() == -1) throw new IllegalStateException(\"Decrypted misc file is empty; rules parsing will fail\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    restoreOp.runRestore();\n} catch (BackupException e) {\n    if (\"Failed to load rules from misc.\".equals(e.getMessage())) {\n        Log.w(TAG, \"Skipping misc rules; data restore continues\", e.getCause());\n    } else throw e;\n}","preventionTips":["Restore backups with a compatible AppManager version","Verify decrypted output looks sane before parsing","Treat misc rules as optional in restore workflows"],"tags":["android","backup","parsing","misc","format"],"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-14T16:17:12.679Z"}