{"record":{"id":"f32418bd85d0bd8b","repo":"MuntashirAkon/AppManager","slug":"backup-with-name-mbackupnames-i-doesn-t-exist","errorCode":null,"errorMessage":"Backup with name ${mBackupNames[i]} doesn't exist.","messagePattern":"Backup with name (.+?) doesn't exist\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/batchops/struct/BatchBackupOptions.java","lineNumber":92,"sourceCode":"    }\n\n    public DeleteOpOptions getDeleteOpOptions(@NonNull String packageName, @UserIdInt int userId) {\n        // For delete operation, backup names (v4) and relative dirs are only set for single\n        // package backups. In all other cases, it only uses base backups.\n        String[] relativeDirs;\n        if (mRelativeDirs != null) {\n            relativeDirs = mRelativeDirs;\n        } else {\n            if (mBackupNames == null || mBackupNames.length == 0) {\n                // Base backup\n                relativeDirs = null;\n            } else {\n                // Generate relative directories\n                relativeDirs = new String[mBackupNames.length];\n                for (int i = 0; i < relativeDirs.length; ++i) {\n                    Backup backup = BackupUtils.retrieveLatestBackupFromDb(userId, mBackupNames[i], packageName);\n                    if (backup == null) {\n                        throw new IllegalArgumentException(\"Backup with name \" + mBackupNames[i] + \" doesn't exist.\");\n                    }\n                    relativeDirs[i] = backup.relativeDir;\n                }\n            }\n        }\n        return new DeleteOpOptions(packageName, userId, relativeDirs);\n    }\n\n    protected BatchBackupOptions(@NonNull Parcel in) {\n        mFlags = in.readInt();\n        mBackupNames = in.createStringArray();\n        mRelativeDirs = in.createStringArray();\n    }\n\n    public static final Creator<BatchBackupOptions> CREATOR = new Creator<BatchBackupOptions>() {\n        @Override\n        @NonNull\n        public BatchBackupOptions createFromParcel(@NonNull Parcel in) {","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/batchops/struct/BatchBackupOptions.java#L74-L110","documentation":"getDeleteOpOptions() resolves each entry of mBackupNames to a latest Backup record via BackupUtils.retrieveLatestBackupFromDb(userId, name, packageName); a null result for any index throws IllegalArgumentException naming that backup. It means at least one requested backup does not exist in the database, so its relative directory cannot be determined for deletion.","triggerScenarios":"Calling deleteBackups with BatchBackupOptions where any name in mBackupNames has no matching backup record in the DB for the given package/user; the loop throws on the first missing name.","commonSituations":"Deleting several backups where some were already removed (e.g. partially successful prior delete or clean-up script); typos in one of many names; user-ID mismatch; database not reflecting on-disk backups.","solutions":["Filter mBackupNames to only names present in the backup DB before calling deleteBackups.","Skip or correct the specific missing name reported in the message and retry the rest.","Verify userId matches the backups' owner user.","Re-sync the backup database if the backups exist on disk but are absent from the DB."],"exampleFix":"// before\nnew BatchBackupOptions(null, new String[]{\"a\", \"b\", \"c\"}).getDeleteOpOptions(pkg, userId);\n// after\nString[] valid = Arrays.stream(names)\n    .filter(n -> BackupUtils.retrieveLatestBackupFromDb(userId, n, pkg) != null)\n    .toArray(String[]::new);\nnew BatchBackupOptions(null, valid).getDeleteOpOptions(pkg, userId);","handlingStrategy":"validation","validationCode":"List<String> valid = Arrays.stream(names)\n    .filter(n -> BackupUtils.retrieveLatestBackupFromDb(userId, n, packageName) != null)\n    .collect(Collectors.toList());\nif (valid.size() != names.length)\n    Log.w(TAG, \"Skipping missing backups: \" + (Arrays.asList(names).removeAll(valid) ? \"\" : \"\"));","typeGuard":null,"tryCatchPattern":"try {\n    options.getDeleteOpOptions(pkg, userId);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"doesn't exist\")) {\n        // remove that name and retry remaining entries\n    } else throw e;\n}","preventionTips":["Pre-filter backup name lists against the DB before delete operations.","Treat deletes as idempotent: ignore already-missing names.","Verify userId consistency across all names in a batch."],"tags":["android","backup","batch-operations","not-found"],"backgroundTag":"record-not-found","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}