{"record":{"id":"0f06395af1445d3e","repo":"microg/GmsCore","slug":"deleteall-was-set-to-true-but-keys-were-also-provi","errorCode":null,"errorMessage":"deleteAll was set to true but keys were also provided","messagePattern":"deleteAll was set to true but keys were also provided","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-auth-blockstore/src/main/java/com/google/android/gms/auth/blockstore/DeleteBytesRequest.java","lineNumber":43,"sourceCode":"\n/**\n * A request to delete app data from BlockStore.\n */\n@SafeParcelable.Class\npublic class DeleteBytesRequest extends AbstractSafeParcelable {\n\n    @Field(value = 1, getterName = \"getKeys\")\n    private final List<String> keys;\n\n    @Field(value = 2, getterName = \"getDeleteAll\")\n    private final boolean deleteAll;\n\n    @Constructor\n    DeleteBytesRequest(@Param(1) List<String> keys, @Param(2) boolean deleteAll) {\n        this.keys = keys;\n        this.deleteAll = deleteAll;\n        if (deleteAll && keys != null && !keys.isEmpty()) {\n            throw new IllegalArgumentException(\"deleteAll was set to true but keys were also provided\");\n        }\n        for (String key : keys) {\n            if (key == null || key.isEmpty()) {\n                throw new IllegalArgumentException(\"Element in keys cannot be null or empty\");\n            }\n        }\n    }\n\n    /**\n     * Returns the list of keys whose associated data, if any, should be deleted.\n     * <p>\n     * An empty list means that no key-based filtering will be performed. In other words, no data will be deleted if the key list is empty and no other\n     * criterion is provided.\n     * <p>\n     * Note that the app data that was stored without an explicit key can be deleted with the default key\n     * {@link BlockstoreClient#DEFAULT_BYTES_DATA_KEY}.\n     */\n    @NonNull","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-auth-blockstore/src/main/java/com/google/android/gms/auth/blockstore/DeleteBytesRequest.java#L25-L61","documentation":"DeleteBytesRequest's constructor enforces mutual exclusivity between the 'keys' list and the 'deleteAll' flag. If deleteAll is true and a non-empty keys list is supplied, the request is contradictory (delete everything vs delete specific keys), so the library throws IllegalArgumentException immediately at construction.","triggerScenarios":"Calling new DeleteBytesRequest(keys, true) with a non-null, non-empty keys list, e.g. building the @Constructor-based request directly (or via protobuf/Parcelable reconstruction) with both fields set.","commonSituations":"Developers set setDeleteAll(true) intending a full wipe but forgot to clear previously added keys, or a builder/serialization path carries stale keys from a prior request; also occurs when hand-constructing the object with @Constructor instead of the Builder.","solutions":["Either clear the keys list (use an empty list) or set deleteAll to false so exactly one deletion mode is chosen.","Prefer DeleteBytesRequest.builder() and set only one of setKeys(...) or setDeleteAll(true).","If a full wipe is intended, call new DeleteBytesRequest(null, true) or the builder with only setDeleteAll(true)."],"exampleFix":"// before\nDeleteBytesRequest req = new DeleteBytesRequest(Arrays.asList(\"k1\"), true);\n// after\nDeleteBytesRequest req = new DeleteBytesRequest(Arrays.asList(\"k1\"), false); // or new DeleteBytesRequest(null, true)","handlingStrategy":"validation","validationCode":"if (deleteAll && keys != null && !keys.isEmpty()) throw new IllegalArgumentException(\"Choose either deleteAll or specific keys, not both\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the Builder rather than the @Constructor; the builder catches this before the request is created.","Encapsulate deletion in a helper with a single mode parameter (all vs keys).","Never call setDeleteAll(true) after setKeys in the same builder chain."],"tags":["android","blockstore","validation","illegal-argument"],"backgroundTag":"mutually-exclusive-flags","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"}