{"record":{"id":"c5c631ef35df4b29","repo":"microg/GmsCore","slug":"parcelablekeyvalue-key-must-be-0","errorCode":null,"errorMessage":"ParcelableKeyValue.key must be > 0","messagePattern":"ParcelableKeyValue\\.key must be > 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-base/src/main/java/com/google/android/wallet/bender3/framework/client/ParcelableKeyValue.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 ParcelableKeyValue extends AbstractSafeParcelable {\n    @Field(2)\n    public final int key;\n    @Field(3)\n    public final String value;\n\n    @Constructor\n    public ParcelableKeyValue(@Param(2) int key, @Param(3) String value) {\n        this.key = key;\n        this.value = value;\n        if (key <= 0) {\n            throw new IllegalArgumentException(\"ParcelableKeyValue.key must be > 0\");\n        }\n        if (value == null) {\n            throw new IllegalArgumentException(\"ParcelableKeyValue.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<ParcelableKeyValue> CREATOR = findCreator(ParcelableKeyValue.class);\n}\n","sourceCodeStart":10,"sourceCodeEnd":42,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-base/src/main/java/com/google/android/wallet/bender3/framework/client/ParcelableKeyValue.java#L10-L42","documentation":"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.","triggerScenarios":"Constructing ParcelableKeyValue(key, value) with key == 0 or negative key, e.g. from unparceled or default-initialized data.","commonSituations":"Rebuilding bender3 framework client payloads from Parcels written by mismatched versions; passing a default 0 key.","solutions":["Assign a valid positive key before construction","Validate the key at the data boundary before wrapping it","Verify sender and receiver use compatible library versions"],"exampleFix":"// before\nParcelableKeyValue kv = new ParcelableKeyValue(key, val); // key defaulted to 0\n// after\nObjects.requireNonNull(val);\nif (key <= 0) key = generateValidKey();\nParcelableKeyValue kv = new ParcelableKeyValue(key, val);","handlingStrategy":"validation","validationCode":"if (key > 0) {\n    ParcelableKeyValue kv = new ParcelableKeyValue(key, value);\n}","typeGuard":null,"tryCatchPattern":"try { new ParcelableKeyValue(key, value); } catch (IllegalArgumentException e) { /* regenerate key or skip */ }","preventionTips":["Never pass default-0 keys","Validate before wrapping into parcelables"],"tags":["validation","parcel","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-14T00:17:10.932Z"}