microg/GmsCore · error · IllegalArgumentException

ParcelableKeyValue.key must be > 0

Error message

ParcelableKeyValue.key must be > 0

What it means

ParcelableKeyValue's @Constructor validates that the key is strictly positive and throws IllegalArgumentException if key <= 0. Like SecurePaymentsData, the key is a protocol field consumed by remote code, so non-positive values are treated as malformed.

Source

Thrown at play-services-base/src/main/java/com/google/android/wallet/bender3/framework/client/ParcelableKeyValue.java:28

import androidx.annotation.NonNull;

import com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelable;
import com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter;

@SafeParcelable.Class
public class ParcelableKeyValue extends AbstractSafeParcelable {
    @Field(2)
    public final int key;
    @Field(3)
    public final String value;

    @Constructor
    public ParcelableKeyValue(@Param(2) int key, @Param(3) String value) {
        this.key = key;
        this.value = value;
        if (key <= 0) {
            throw new IllegalArgumentException("ParcelableKeyValue.key must be > 0");
        }
        if (value == null) {
            throw new IllegalArgumentException("ParcelableKeyValue.value must not be null");
        }
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        CREATOR.writeToParcel(this, dest, flags);
    }

    public static final SafeParcelableCreatorAndWriter<ParcelableKeyValue> CREATOR = findCreator(ParcelableKeyValue.class);
}

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Assign a valid positive key before construction
  2. Validate the key at the data boundary before wrapping it
  3. Verify sender and receiver use compatible library versions

Example fix

// before
ParcelableKeyValue kv = new ParcelableKeyValue(key, val); // key defaulted to 0
// after
Objects.requireNonNull(val);
if (key <= 0) key = generateValidKey();
ParcelableKeyValue kv = new ParcelableKeyValue(key, val);
Defensive patterns

Strategy: validation

Validate before calling

if (key > 0) {
    ParcelableKeyValue kv = new ParcelableKeyValue(key, value);
}

Try / catch

try { new ParcelableKeyValue(key, value); } catch (IllegalArgumentException e) { /* regenerate key or skip */ }

Prevention

When it happens

Trigger: Constructing ParcelableKeyValue(key, value) with key == 0 or negative key, e.g. from unparceled or default-initialized data.

Common situations: Rebuilding bender3 framework client payloads from Parcels written by mismatched versions; passing a default 0 key.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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