microg/GmsCore · error · IllegalArgumentException

SecurePaymentsData.key must be > 0

Error message

SecurePaymentsData.key must be > 0

What it means

SecurePaymentsData's @Constructor validates that the key is strictly positive and throws IllegalArgumentException otherwise. The key is a protocol identifier shared with Google Play services, so key <= 0 is considered a malformed record.

Source

Thrown at play-services-base/src/main/java/com/google/android/gms/wallet/firstparty/pm/SecurePaymentsData.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 SecurePaymentsData extends AbstractSafeParcelable {
    @Field(2)
    public final int key;
    @Field(3)
    public final String value;

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

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

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

View on GitHub (pinned to 157c9d86ac)

Solutions

  1. Ensure key is assigned a positive identifier before construction
  2. Validate the source data before building SecurePaymentsData
  3. Check that the Parcel was written by a compatible library version

Example fix

// before
SecurePaymentsData d = new SecurePaymentsData(keyFromServer, value); // key = 0
// after
if (keyFromServer <= 0) throw new DataException("missing key");
SecurePaymentsData d = new SecurePaymentsData(keyFromServer, value);
Defensive patterns

Strategy: validation

Validate before calling

if (key > 0 && value != null) {
    SecurePaymentsData d = new SecurePaymentsData(key, value);
}

Try / catch

try { new SecurePaymentsData(key, value); } catch (IllegalArgumentException e) { log(e); /* drop record */ }

Prevention

When it happens

Trigger: Constructing SecurePaymentsData(key, value) via the reflected/Parcel constructor with key <= 0, including key == 0.

Common situations: Restoring from a Parcel that was written by a different version of the payload; deserializing server/wallet data with a missing or default-zero 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/75cd27d288770732. Report an issue: GitHub.