{"record":{"id":"933e44407cad64a9","repo":"microg/GmsCore","slug":"value-is-not-a-string","errorCode":null,"errorMessage":"Value is not a string.","messagePattern":"Value is not a string\\.","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"play-services-fitness/src/main/java/com/google/android/gms/fitness/data/Value.java","lineNumber":107,"sourceCode":"\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     */\n    @NonNull\n    public String asString() {\n        if (format != FORMAT_STRING) throw new IllegalStateException(\"Value is not a string.\");\n        if (stringValue == null) return \"\";\n        return stringValue;\n    }\n\n    /**\n     * Clears any value currently associated with the given {@code key} in the map. This method can be used only on map values.\n     *\n     * @param key The key you're modifying.\n     * @deprecated Use {@link DataPoint.Builder} to construct new {@link DataPoint} instances.\n     */\n    @Deprecated\n    public void clearKey(String key) {\n        if (format != FORMAT_MAP) throw new IllegalStateException(\"Value is not a map.\");\n        if (mapValue != null) {\n            mapValue.remove(key);\n        }\n    }\n","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-fitness/src/main/java/com/google/android/gms/fitness/data/Value.java#L89-L125","documentation":"Format guard in fitness Value.asString: the Value's format is not FORMAT_STRING, so the internal stringValue cannot be returned. It fires when a numeric- or map-formatted Value is read through the string accessor.","triggerScenarios":"Thrown at play-services-fitness/src/main/java/com/google/android/gms/fitness/data/Value.java:107 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check getFormat() == Field.FORMAT_STRING before calling asString()","Use the accessor matching the Value's actual format"],"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"}