MuntashirAkon/AppManager · error · BackupException

Rules file is missing.

Error message

Rules file is missing.

What it means

verifyRules() cannot obtain the backup's rules file (mBackupItem.getRulesFile() throws IOException) while mBackupMetadata.hasRules is true — the metadata declares that rules were backed up (e.g. net-policy/ifw rules), but the actual rules file is absent from the backup directory. If hasRules were false, a missing rules file is expected and silently skipped.

Source

Thrown at app/src/main/java/io/github/muntashirakon/AppManager/backup/VerifyOp.java:218

            // There are no permissions, just skip
            return;
        }
        String checksum = DigestUtils.getHexDigest(mBackupInfo.checksumAlgo, miscFile);
        if (!checksum.equals(mChecksum.get(miscFile.getName()))) {
            throw new BackupException("Could not verify extras." +
                    "\nFile: " + miscFile.getName() +
                    "\nFound: " + checksum +
                    "\nRequired: " + mChecksum.get(miscFile.getName()));
        }
    }

    private void verifyRules() throws BackupException {
        Path rulesFile;
        try {
            rulesFile = mBackupItem.getRulesFile();
        } catch (IOException e) {
            if (mBackupMetadata.hasRules) {
                throw new BackupException("Rules file is missing.", e);
            } else {
                // There are no rules, just skip
                return;
            }
        }
        String checksum = DigestUtils.getHexDigest(mBackupInfo.checksumAlgo, rulesFile);
        if (!checksum.equals(mChecksum.get(rulesFile.getName()))) {
            throw new BackupException("Could not verify rules file." +
                    "\nFile: " + rulesFile.getName() +
                    "\nFound: " + checksum +
                    "\nRequired: " + mChecksum.get(rulesFile.getName()));
        }
    }
}

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Copy the missing rules file from the original backup into the backup directory.
  2. Recreate the backup ensuring it completes the rules step.
  3. If rules aren't needed, clear the hasRules flag in the metadata (with matching checksum update) or unset the backupRules flag so verification skips it.
  4. Inspect the cause IOException for permission/path issues in the backup directory.

Example fix

// before
//   Rules file is missing. (metadata.hasRules = true, file absent)
// after: copy the rules file back, or set hasRules=false when no rules exist
// metadata.hasRules = false; // + update metadata checksum entry
Defensive patterns

Strategy: validation

Validate before calling

// Ensure declared rules file exists before verify
if (flags.backupRules() && metadata.hasRules) {
    try {
        backupItem.getRulesFile();
    } catch (IOException e) {
        throw new IllegalStateException("rules file declared but missing: copy it back or set hasRules=false");
    }
}

Try / catch

try {
    verifyOp.verify();
} catch (BackupException e) {
    if (e.getMessage().equals("Rules file is missing.")) {
        // re-copy the rules file or clear hasRules in metadata (and update checksums)
    }
}

Prevention

When it happens

Trigger: verify() -> verifyRules() when mBackupFlags.backupRules() is set; getRulesFile() throws IOException AND mBackupMetadata.hasRules == true — a declared rules file that is missing on disk.

Common situations: Rules file (e.g. ifw/net-policy XML) deleted or not copied when moving the backup folder; backup interrupted before the rules step finished writing yet metadata still recorded hasRules=true; selective file sync (cloud) skipped the small rules file.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/3929aa8a7f69e805. Report an issue: GitHub.