{"record":{"id":"270596fb379887a9","repo":"microg/GmsCore","slug":"value-is-not-a-float","errorCode":null,"errorMessage":"Value is not a float.","messagePattern":"Value is not a float\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"play-services-fitness/src/main/java/com/google/android/gms/fitness/data/Value.java","lineNumber":86,"sourceCode":"\n    /**\n     * Returns the value of this object as an activity. The integer representation of the activity is converted to a String prior to returning.\n     *\n     * @return One of the constants from {@link FitnessActivities}; {@link FitnessActivities#UNKNOWN} if the object does not hold a valid activity\n     * representation\n     * @throws IllegalStateException If this {@link Value} does not correspond to a {@link com.google.android.gms.fitness.data.Field#FORMAT_INT32}\n     */\n    public String asActivity() {\n        return null; // TODO\n    }\n\n    /**\n     * Returns the value of this object as a float.\n     *\n     * @throws IllegalStateException If this {@link Value} does not correspond to a {@link com.google.android.gms.fitness.data.Field#FORMAT_FLOAT}\n     */\n    public float asFloat() {\n        if (format != FORMAT_FLOAT) throw new IllegalStateException(\"Value is not a float.\");\n        return value;\n    }\n\n    /**\n     * Returns the value of this object as a int.\n     *\n     * @throws IllegalStateException If this {@link Value} does not correspond to a {@link com.google.android.gms.fitness.data.Field#FORMAT_INT32}\n     */\n    public int asInt() {\n        if (format != FORMAT_INT32) throw new IllegalStateException(\"Value is not a int.\");\n        return Float.floatToRawIntBits(this.value);\n    }\n\n    /**\n     * Returns the value of this object as a string.\n     *\n     * @throws IllegalStateException If this {@link Value} does not correspond to a {@link com.google.android.gms.fitness.data.Field#FORMAT_STRING}\n     */","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-fitness/src/main/java/com/google/android/gms/fitness/data/Value.java#L68-L104","documentation":"Format guard in fitness Value.asFloat: the Value's format is not FORMAT_FLOAT (stored as int, string, or map), so the internal representation cannot be safely returned as a float. The mismatch between the field's declared format and the accessor is at fault.","triggerScenarios":"Thrown at play-services-fitness/src/main/java/com/google/android/gms/fitness/data/Value.java:86 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check getFormat() against Field.FORMAT_FLOAT before calling asFloat()","Use the accessor matching the value's actual format (asInt/asString)"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}