{"record":{"id":"f84fc2acc489d732","repo":"microg/GmsCore","slug":"not-a-double-type","errorCode":null,"errorMessage":"Not a double type","messagePattern":"Not a double type","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-phenotype/src/main/java/com/google/android/gms/phenotype/Flag.java","lineNumber":83,"sourceCode":"        this.flagType = flagType;\n    }\n\n    public long getLong() {\n        if (dataType == DATA_TYPE_LONG)\n            return longValue;\n        throw new IllegalArgumentException(\"Not a long type\");\n    }\n\n    public boolean getBool() {\n        if (dataType == DATA_TYPE_BOOL)\n            return boolValue;\n        throw new IllegalArgumentException(\"Not a boolean type\");\n    }\n\n    public double getDouble() {\n        if (dataType == DATA_TYPE_DOUBLE)\n            return doubleValue;\n        throw new IllegalArgumentException(\"Not a double type\");\n    }\n\n    public String getString() {\n        if (dataType == DATA_TYPE_STRING)\n            return stringValue;\n        throw new IllegalArgumentException(\"Not a String type\");\n    }\n\n    public byte[] getBytes() {\n        if (dataType == DATA_TYPE_BYTES)\n            return bytesValue;\n        throw new IllegalArgumentException(\"Not a bytes type\");\n    }\n\n    public static final int DATA_TYPE_LONG = 1;\n    public static final int DATA_TYPE_BOOL = 2;\n    public static final int DATA_TYPE_DOUBLE = 3;\n    public static final int DATA_TYPE_STRING = 4;","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-phenotype/src/main/java/com/google/android/gms/phenotype/Flag.java#L65-L101","documentation":"Flag.getDouble() throws IllegalArgumentException(\"Not a double type\") when the flag's dataType is not DATA_TYPE_DOUBLE. Each typed accessor in Flag validates the dataType discriminator before returning its field, so reading the double field of a flag that is not of double type fails fast instead of returning an undefined value.","triggerScenarios":"Calling Flag.getDouble() on a Flag whose dataType is DATA_TYPE_LONG (1), DATA_TYPE_BOOL (2), DATA_TYPE_STRING (4), or DATA_TYPE_BYTES (5) instead of DATA_TYPE_DOUBLE (3).","commonSituations":"Server experiment changed a flag from double to long or string; generic flag-parsing code that assumes a fixed type per field; migrating from another config library where numbers were uniformly doubles.","solutions":["Check flag.getDataType() == Flag.DATA_TYPE_DOUBLE before calling getDouble()","If numeric values may be long, accept DATA_TYPE_LONG and widen to double via ((double) flag.getLong())","Switch over DATA_TYPE_* constants and handle each typed case","Verify the server-side flag type is still double"],"exampleFix":"// before\ndouble d = flag.getDouble();\n// after\ndouble d;\nif (flag.getDataType() == Flag.DATA_TYPE_DOUBLE) d = flag.getDouble();\nelse if (flag.getDataType() == Flag.DATA_TYPE_LONG) d = (double) flag.getLong();\nelse d = 0.0;","handlingStrategy":"type-guard","validationCode":"if (flag.getDataType() != Flag.DATA_TYPE_DOUBLE) { throw new IllegalStateException(\"flag is not a double: \" + flag.getDataType()); }","typeGuard":"static boolean isDoubleFlag(Flag f) { return f != null && f.getDataType() == Flag.DATA_TYPE_DOUBLE; }","tryCatchPattern":"try { double v = flag.getDouble(); } catch (IllegalArgumentException e) { log.warn(\"Flag type mismatch\", e); v = DEFAULT_DOUBLE; }","preventionTips":["Check dataType == DATA_TYPE_DOUBLE before getDouble()","Accept DATA_TYPE_LONG as a numeric fallback when widening is acceptable","Keep numeric flag handling in a shared utility","Verify flag type in the phenotype console after edits"],"tags":["android","phenotype","type-mismatch","flags"],"backgroundTag":"type-mismatch","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"}