{"record":{"id":"75cd27d288770732","repo":"microg/GmsCore","slug":"securepaymentsdata-key-must-be-0","errorCode":null,"errorMessage":"SecurePaymentsData.key must be > 0","messagePattern":"SecurePaymentsData\\.key must be > 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-base/src/main/java/com/google/android/gms/wallet/firstparty/pm/SecurePaymentsData.java","lineNumber":28,"sourceCode":"import androidx.annotation.NonNull;\n\nimport com.google.android.gms.common.internal.safeparcel.AbstractSafeParcelable;\nimport com.google.android.gms.common.internal.safeparcel.SafeParcelable;\nimport com.google.android.gms.common.internal.safeparcel.SafeParcelableCreatorAndWriter;\n\n@SafeParcelable.Class\npublic class SecurePaymentsData extends AbstractSafeParcelable {\n    @Field(2)\n    public final int key;\n    @Field(3)\n    public final String value;\n\n    @Constructor\n    public SecurePaymentsData(@Param(2) int key, @Param(3) String value) {\n        this.key = key;\n        this.value = value;\n        if (key <= 0) {\n            throw new IllegalArgumentException(\"SecurePaymentsData.key must be > 0\");\n        }\n        if (value == null) {\n            throw new IllegalArgumentException(\"SecurePaymentsData.value must not be null\");\n        }\n    }\n\n    @Override\n    public void writeToParcel(@NonNull Parcel dest, int flags) {\n        CREATOR.writeToParcel(this, dest, flags);\n    }\n\n    public static final SafeParcelableCreatorAndWriter<SecurePaymentsData> CREATOR = findCreator(SecurePaymentsData.class);\n}\n","sourceCodeStart":10,"sourceCodeEnd":42,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-base/src/main/java/com/google/android/gms/wallet/firstparty/pm/SecurePaymentsData.java#L10-L42","documentation":"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.","triggerScenarios":"Constructing SecurePaymentsData(key, value) via the reflected/Parcel constructor with key <= 0, including key == 0.","commonSituations":"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.","solutions":["Ensure key is assigned a positive identifier before construction","Validate the source data before building SecurePaymentsData","Check that the Parcel was written by a compatible library version"],"exampleFix":"// before\nSecurePaymentsData d = new SecurePaymentsData(keyFromServer, value); // key = 0\n// after\nif (keyFromServer <= 0) throw new DataException(\"missing key\");\nSecurePaymentsData d = new SecurePaymentsData(keyFromServer, value);","handlingStrategy":"validation","validationCode":"if (key > 0 && value != null) {\n    SecurePaymentsData d = new SecurePaymentsData(key, value);\n}","typeGuard":null,"tryCatchPattern":"try { new SecurePaymentsData(key, value); } catch (IllegalArgumentException e) { log(e); /* drop record */ }","preventionTips":["Validate keys at the data boundary","Keep parcel writer/reader versions in sync"],"tags":["validation","wallet","android"],"backgroundTag":"invalid-argument-value","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"}