{"record":{"id":"86e9270f678bde3e","repo":"microg/GmsCore","slug":"securepaymentsdata-value-must-not-be-null","errorCode":null,"errorMessage":"SecurePaymentsData.value must not be null","messagePattern":"SecurePaymentsData\\.value must not be null","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":31,"sourceCode":"import 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":13,"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#L13-L42","documentation":"SecurePaymentsData's constructor requires a non-null value String and throws IllegalArgumentException when it is null. The value is parcelled to Google Play services, which cannot accept a null payload for this field.","triggerScenarios":"Calling new SecurePaymentsData(key, null), or unparcelling data where the value string was not written.","commonSituations":"Mapping backend responses where the value field is absent (JSON null) straight into the constructor.","solutions":["Ensure value is non-null before constructing","Substitute an empty string if a null value is semantically acceptable","Reject/repair the source record before building the object"],"exampleFix":"// before\nSecurePaymentsData d = new SecurePaymentsData(key, json.optString(\"value\", null)); // may be null\n// after\nString v = json.optString(\"value\", \"\");\nSecurePaymentsData d = new SecurePaymentsData(key, v);","handlingStrategy":"validation","validationCode":"if (value != null) {\n    SecurePaymentsData d = new SecurePaymentsData(key, value);\n}","typeGuard":"// Java lacks null narrowing; use Objects.requireNonNull\nString v = Objects.requireNonNull(value, \"value required\");","tryCatchPattern":"try { new SecurePaymentsData(key, value); } catch (IllegalArgumentException e) { /* default value to \"\" or skip */ }","preventionTips":["Null-check values from JSON/backend before constructing","Prefer empty-string defaults over null"],"tags":["null","validation","wallet"],"backgroundTag":"null-argument","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"}