{"record":{"id":"a7c559a3683829a8","repo":"microg/GmsCore","slug":"deleteall-true-but-keys-are-provided","errorCode":null,"errorMessage":"deleteAll=true but keys are provided","messagePattern":"deleteAll=true but keys are provided","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"play-services-auth-blockstore/src/main/java/com/google/android/gms/auth/blockstore/DeleteBytesRequest.java","lineNumber":105,"sourceCode":"    /**\n     * A builder for {@link DeleteBytesRequest} objects.\n     */\n    public static class Builder {\n        private final List<String> keyList = new ArrayList<>();\n        private boolean deleteAll = false;\n\n        /**\n         * Constructor for the {@link DeleteBytesRequest.Builder} class.\n         */\n        public Builder() {\n        }\n\n        /**\n         * Builds and returns the {@link DeleteBytesRequest} object.\n         */\n        public DeleteBytesRequest build() {\n            if (deleteAll && !keyList.isEmpty()) {\n                throw new IllegalStateException(\"deleteAll=true but keys are provided\");\n            }\n            return new DeleteBytesRequest(new ArrayList<>(keyList), deleteAll);\n        }\n\n        /**\n         * Sets whether or not all app's Block Store data should be deleted.\n         * <p>\n         * The default is {@code false}.\n         * <p>\n         * Note that if {@code deleteAll} is set to true, then you should NOT set any other deletion criterion, e.g. {@code keys} should be empty. Otherwise, an\n         * IllegalStateException will be thrown.\n         */\n        public Builder setDeleteAll(boolean deleteAll) {\n            this.deleteAll = deleteAll;\n            return this;\n        }\n\n        /**","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-auth-blockstore/src/main/java/com/google/android/gms/auth/blockstore/DeleteBytesRequest.java#L87-L123","documentation":"DeleteBytesRequest.Builder.build() performs the same mutual-exclusivity check as the constructor: if setDeleteAll(true) was called while keyList is non-empty, build() throws IllegalStateException. This is the builder-time guard so the invalid state never reaches the constructor.","triggerScenarios":"Chaining DeleteBytesRequest.builder().setKeys(...)...setDeleteAll(true).build() — any builder invocation that combines a non-empty keyList with deleteAll=true.","commonSituations":"Copying settings from an existing builder or request and turning on deleteAll without clearing keys; calling setDeleteAll(true) after adding keys in conditional code paths.","solutions":["Call keyList.clear() / remove setKeys calls, or don't call setDeleteAll(true) — pick one deletion mode.","Run the builder twice in different branches: one branch builds a keys-only request, the other builds deleteAll(true) with no keys.","Validate the intent before building: if wiping all data, construct via DeleteBytesRequest.builder().setDeleteAll(true).build() only."],"exampleFix":"// before\nbuilder.setKeys(keys).setDeleteAll(true).build();\n// after\nif (deleteAll) {\n    req = DeleteBytesRequest.builder().setDeleteAll(true).build();\n} else {\n    req = DeleteBytesRequest.builder().setKeys(keys).build();\n}","handlingStrategy":"validation","validationCode":"if (deleteAll && !keyList.isEmpty()) { /* fix before build() */ keyList.clear(); }","typeGuard":null,"tryCatchPattern":"try { req = builder.build(); } catch (IllegalStateException e) { log.error(\"Invalid DeleteBytesRequest: \" + e.getMessage()); }","preventionTips":["Write two distinct builder paths: one for deleteAll, one for key-based deletion.","Avoid reusing a single Builder instance across code paths where flags may conflict.","Add an app-level assertion before building."],"tags":["android","blockstore","builder","validation"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}