{"record":{"id":"57c4ce0c4678530d","repo":"beemdevelopment/Aegis","slug":"invalid-backups-versioning-strategy","errorCode":null,"errorMessage":"Invalid backups versioning strategy","messagePattern":"Invalid backups versioning strategy","errorType":"exception","errorClass":"VaultRepositoryException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/com/beemdevelopment/aegis/vault/VaultBackupManager.java","lineNumber":80,"sourceCode":"                _prefs.setBuiltInBackupResult(new Preferences.BackupResult(null));\n            } catch (VaultRepositoryException | VaultBackupPermissionException e) {\n                e.printStackTrace();\n                _prefs.setBuiltInBackupResult(new Preferences.BackupResult(e));\n            }\n        });\n    }\n\n    private void createBackup(File tempFile, BackupsVersioningStrategy strategy, Uri uri, int versionsToKeep)\n            throws VaultRepositoryException, VaultBackupPermissionException {\n        if (uri == null) {\n            throw new VaultRepositoryException(\"getBackupsLocation returned null\");\n        }\n        if (strategy == BackupsVersioningStrategy.SINGLE_BACKUP) {\n            createBackup(tempFile, uri);\n        } else if (strategy == BackupsVersioningStrategy.MULTIPLE_BACKUPS) {\n            createBackup(tempFile, uri, versionsToKeep);\n        } else {\n            throw new VaultRepositoryException(\"Invalid backups versioning strategy\");\n        }\n    }\n\n    private void createBackup(File tempFile, Uri fileUri)\n            throws VaultRepositoryException, VaultBackupPermissionException {\n        Log.i(TAG, String.format(\"Creating backup at %s\", fileUri));\n        try {\n            if (!hasPermissionsAt(fileUri)) {\n                throw new VaultBackupPermissionException(\"No persisted URI permissions\");\n            }\n            ContentResolver resolver = _context.getContentResolver();\n            try (FileInputStream inStream = new FileInputStream(tempFile);\n                 OutputStream outStream = resolver.openOutputStream(fileUri, \"wt\")\n            ) {\n                if (outStream == null) {\n                    throw new IOException(\"openOutputStream returned null\");\n                }\n                IOUtils.copy(inStream, outStream);","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/beemdevelopment/Aegis/blob/d6f4e5925a97e4e91593f1542085eae03432a759/app/src/main/java/com/beemdevelopment/aegis/vault/VaultBackupManager.java#L62-L98","documentation":"Exhaustiveness guard in VaultBackupManager.createBackup: thrown as VaultRepositoryException when the BackupsVersioningStrategy value is neither SINGLE_BACKUP nor MULTIPLE_BACKUP. This can only happen if a new strategy enum constant is added without extending createBackup, or a corrupt/unknown strategy is deserialized from preferences; it prevents backups proceeding with undefined versioning behavior.","triggerScenarios":"Thrown at app/src/main/java/com/beemdevelopment/aegis/vault/VaultBackupManager.java:80 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace the bare else-branch throw with an exhaustive switch over BackupsVersioningStrategy so new enum values cause a compile error rather than a runtime failure","Validate strategy != null and is a known value in scheduleBackup before dispatching to createBackup","Include the actual strategy value in the exception message to make misconfiguration diagnosable","Add a unit test covering every enum constant to guarantee each dispatch path is handled"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d6f4e5925a97e4e91593f1542085eae03432a759","analyzedAt":"2026-09-08T00:46:31.111Z","contentChangedAt":"2026-09-08T00:46:31.111Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}