{"record":{"id":"a990945ac95a1e00","repo":"MuntashirAkon/AppManager","slug":"keystore-files-should-ve-existed-but-they-didn-t","errorCode":null,"errorMessage":"KeyStore files should've existed but they didn't","messagePattern":"KeyStore files should've existed but they didn't","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java","lineNumber":422,"sourceCode":"                mIsInstalled = true;\n            } catch (Exception e) {\n                throw new BackupException(\"Apparently the install wasn't complete in the previous section.\", e);\n            }\n        }\n    }\n\n    private void restoreKeyStore() throws BackupException {\n        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {\n            // keystore v2 is not supported.\n            Log.w(TAG, \"Ignoring KeyStore backups for %s\", mPackageName);\n            return;\n        }\n        if (mPackageInfo == null) {\n            throw new BackupException(\"KeyStore restore is requested but the app isn't installed.\");\n        }\n        Path[] keyStoreFiles = mBackupItem.getKeyStoreFiles();\n        if (keyStoreFiles.length == 0) {\n            throw new BackupException(\"KeyStore files should've existed but they didn't\");\n        }\n        if (!mRequestedFlags.skipSignatureCheck()) {\n            String checksum;\n            for (Path file : keyStoreFiles) {\n                checksum = DigestUtils.getHexDigest(mBackupInfo.checksumAlgo, file);\n                if (!checksum.equals(mChecksum.get(file.getName()))) {\n                    throw new BackupException(\"KeyStore file verification failed.\" +\n                            \"\\nFile: \" + file +\n                            \"\\nFound: \" + checksum +\n                            \"\\nRequired: \" + mChecksum.get(file.getName()));\n                }\n            }\n        }\n        // Decrypt sources\n        try {\n            keyStoreFiles = mBackupItem.decrypt(keyStoreFiles);\n        } catch (IOException e) {\n            throw new BackupException(\"Failed to decrypt \" + Arrays.toString(keyStoreFiles), e);","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/RestoreOp.java#L404-L440","documentation":"restoreKeyStore expects the backup item to contain keystore files when a KeyStore restore was requested. getKeyStoreFiles() returned an empty array — the backup claims keystore data but no keystore files are present in the backup directory. AppManager treats this as a broken/incomplete backup.","triggerScenarios":"mBackupItem.getKeyStoreFiles() returns length 0: the keystore.tar* files were deleted from the backup folder, the backup was created without keystore capture, or the backup item's file listing is stale.","commonSituations":"Manually copying backups and omitting keystore files; storage cleaners deleting 'unused' files; backups created before keystore support was added; corrupted backup manifest not matching on-disk contents.","solutions":["Restore the missing keystore files into the backup directory from the original backup source.","Re-create the backup with keystore capture enabled if the files were never backed up.","Disable the KeyStore restore option if keystore files are intentionally absent.","Verify backup integrity (all files listed in metadata exist) before starting a restore."],"exampleFix":"// before\nPath[] keyStoreFiles = mBackupItem.getKeyStoreFiles();\n// after\nPath[] keyStoreFiles = mBackupItem.getKeyStoreFiles();\nif (keyStoreFiles.length == 0 && mRequestedFlags.backupKeyStore()) {\n    throw new BackupException(\"Backup is missing keystore files; re-create the backup\");\n}","handlingStrategy":"validation","validationCode":"Path[] ks = mBackupItem.getKeyStoreFiles();\nif (flags.backupKeyStore() && ks.length == 0) throw new IllegalStateException(\"Backup missing keystore files\");","typeGuard":null,"tryCatchPattern":"if (keyStoreFiles.length == 0) { throw new BackupException(\"KeyStore files should've existed but they didn't\"); } // catch and either re-create backup or disable keystore flag","preventionTips":["Validate backup completeness (all expected files present) before restore","Copy backups wholesale, never selectively omit keystore files","Keep backup manifests in sync with on-disk contents","Disable the keystore flag when the backup knowingly lacks keystore data"],"tags":["android","keystore","backup-integrity"],"backgroundTag":"empty-result-set","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"}