{"record":{"id":"ba7b06f25c9c7a27","repo":"microg/GmsCore","slug":"retrieveall-was-set-to-true-but-other-constraint-s","errorCode":null,"errorMessage":"retrieveAll was set to true but other constraint(s) was also provided: keys","messagePattern":"retrieveAll was set to true but other constraint\\(s\\) was also provided: keys","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-auth-blockstore/src/main/java/com/google/android/gms/auth/blockstore/RetrieveBytesRequest.java","lineNumber":41,"sourceCode":"import java.util.Collections;\nimport java.util.List;\n\n/**\n * A request to retrieve app data from BlockStore.\n */\n@SafeParcelable.Class\npublic class RetrieveBytesRequest extends AbstractSafeParcelable {\n\n    @Field(value = 1, getterName = \"getKeys\")\n    private final List<String> keys;\n\n    @Field(value = 2, getterName = \"getRetrieveAll\")\n    private final boolean retrieveAll;\n\n    @Constructor\n    RetrieveBytesRequest(@Param(1) List<String> keys, @Param(2) boolean retrieveAll) {\n        if (retrieveAll && keys != null && !keys.isEmpty()) {\n            throw new IllegalArgumentException(\"retrieveAll was set to true but other constraint(s) was also provided: keys\");\n        }\n        this.retrieveAll = retrieveAll;\n\n        List<String> tmp = new ArrayList<>();\n        if (keys != null) {\n            for (String k : keys) {\n                if (k == null || k.isEmpty()) {\n                    throw new IllegalArgumentException(\"Element in keys cannot be null or empty\");\n                }\n                tmp.add(k);\n            }\n        }\n        this.keys = Collections.unmodifiableList(tmp);\n    }\n\n    /**\n     * Returns the list of keys whose associated data, if any, should be retrieved.\n     * <p>","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-auth-blockstore/src/main/java/com/google/android/gms/auth/blockstore/RetrieveBytesRequest.java#L23-L59","documentation":"RetrieveBytesRequest's constructor requires that when retrieveAll=true, no other constraint (specifically a non-empty keys list) is provided. Combining 'retrieve everything' with specific keys is contradictory, so it throws IllegalArgumentException.","triggerScenarios":"Calling new RetrieveBytesRequest(keys, true) with a non-null, non-empty keys list, e.g. hand-constructing the request with both fields set.","commonSituations":"A flag flip to 'retrieve all' in code that still passes previously configured keys; direct construction bypassing the Builder, which would otherwise catch this earlier.","solutions":["Set keys to null or an empty list when retrieveAll is true.","Or set retrieveAll to false when specific keys are intended.","Use RetrieveBytesRequest.builder() and set only retrieveAll(true) or the key list, never both."],"exampleFix":"// before\nRetrieveBytesRequest req = new RetrieveBytesRequest(keys, true);\n// after\nRetrieveBytesRequest req = retrieveAll ? new RetrieveBytesRequest(null, true) : new RetrieveBytesRequest(keys, false);","handlingStrategy":"validation","validationCode":"if (retrieveAll && keys != null && !keys.isEmpty()) throw new IllegalArgumentException(\"retrieveAll excludes specific keys\");","typeGuard":null,"tryCatchPattern":"try { req = new RetrieveBytesRequest(keys, retrieveAll); } catch (IllegalArgumentException e) { /* pick one mode and retry */ }","preventionTips":["Use the Builder and set either retrieveAll(true) or keys, never both.","Model the two modes as separate functions so the compiler discourages mixing them.","Reset builders when changing retrieval mode."],"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-14T05:17:10.506Z"}