microg/GmsCore · error · IllegalArgumentException

retrieveAll was set to true but other constraint(s) was also

Error message

retrieveAll was set to true but other constraint(s) was also provided: keys

What it means

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.

Source

Thrown at play-services-auth-blockstore/src/main/java/com/google/android/gms/auth/blockstore/RetrieveBytesRequest.java:41

import java.util.Collections;
import java.util.List;

/**
 * A request to retrieve app data from BlockStore.
 */
@SafeParcelable.Class
public class RetrieveBytesRequest extends AbstractSafeParcelable {

    @Field(value = 1, getterName = "getKeys")
    private final List<String> keys;

    @Field(value = 2, getterName = "getRetrieveAll")
    private final boolean retrieveAll;

    @Constructor
    RetrieveBytesRequest(@Param(1) List<String> keys, @Param(2) boolean retrieveAll) {
        if (retrieveAll && keys != null && !keys.isEmpty()) {
            throw new IllegalArgumentException("retrieveAll was set to true but other constraint(s) was also provided: keys");
        }
        this.retrieveAll = retrieveAll;

        List<String> tmp = new ArrayList<>();
        if (keys != null) {
            for (String k : keys) {
                if (k == null || k.isEmpty()) {
                    throw new IllegalArgumentException("Element in keys cannot be null or empty");
                }
                tmp.add(k);
            }
        }
        this.keys = Collections.unmodifiableList(tmp);
    }

    /**
     * Returns the list of keys whose associated data, if any, should be retrieved.
     * <p>

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Set keys to null or an empty list when retrieveAll is true.
  2. Or set retrieveAll to false when specific keys are intended.
  3. Use RetrieveBytesRequest.builder() and set only retrieveAll(true) or the key list, never both.

Example fix

// before
RetrieveBytesRequest req = new RetrieveBytesRequest(keys, true);
// after
RetrieveBytesRequest req = retrieveAll ? new RetrieveBytesRequest(null, true) : new RetrieveBytesRequest(keys, false);
Defensive patterns

Strategy: validation

Validate before calling

if (retrieveAll && keys != null && !keys.isEmpty()) throw new IllegalArgumentException("retrieveAll excludes specific keys");

Try / catch

try { req = new RetrieveBytesRequest(keys, retrieveAll); } catch (IllegalArgumentException e) { /* pick one mode and retry */ }

Prevention

When it happens

Trigger: Calling new RetrieveBytesRequest(keys, true) with a non-null, non-empty keys list, e.g. hand-constructing the request with both fields set.

Common situations: 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.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06). Data as JSON: /api/errors/ba7b06f25c9c7a27. Report an issue: GitHub.