{"record":{"id":"51ed1c796f0fe48b","repo":"dgraph-io/dgraph","slug":"expected-value-of-type-float64-got-v","errorCode":null,"errorMessage":"Expected value of type float64. Got : %v","messagePattern":"Expected value of type float64\\. Got : (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"types/conversion.go","lineNumber":663,"sourceCode":"\t\t\treturn def, errors.Errorf(\"Expected value of type string. Got : %v\", value)\n\t\t}\n\t\treturn &api.Value{Val: &api.Value_StrVal{StrVal: v}}, nil\n\tcase DefaultID:\n\t\tvar v string\n\t\tif v, ok = value.(string); !ok {\n\t\t\treturn def, errors.Errorf(\"Expected value of type string. Got : %v\", value)\n\t\t}\n\t\treturn &api.Value{Val: &api.Value_DefaultVal{DefaultVal: v}}, nil\n\tcase IntID:\n\t\tvar v int64\n\t\tif v, ok = value.(int64); !ok {\n\t\t\treturn def, errors.Errorf(\"Expected value of type int64. Got : %v\", value)\n\t\t}\n\t\treturn &api.Value{Val: &api.Value_IntVal{IntVal: v}}, nil\n\tcase FloatID:\n\t\tvar v float64\n\t\tif v, ok = value.(float64); !ok {\n\t\t\treturn def, errors.Errorf(\"Expected value of type float64. Got : %v\", value)\n\t\t}\n\t\treturn &api.Value{Val: &api.Value_DoubleVal{DoubleVal: v}}, nil\n\tcase BoolID:\n\t\tvar v bool\n\t\tif v, ok = value.(bool); !ok {\n\t\t\treturn def, errors.Errorf(\"Expected value of type bool. Got : %v\", value)\n\t\t}\n\t\treturn &api.Value{Val: &api.Value_BoolVal{BoolVal: v}}, nil\n\tcase BinaryID:\n\t\tvar v []byte\n\t\tif v, ok = value.([]byte); !ok {\n\t\t\treturn def, errors.Errorf(\"Expected value of type []byte. Got : %v\", value)\n\t\t}\n\t\treturn &api.Value{Val: &api.Value_BytesVal{BytesVal: v}}, nil\n\t// Geo, datetime, and BigFloat are stored in binary format in the N-Quad, so lets\n\t// convert them here.\n\tcase BigFloatID:\n\t\tb, err := toBinary(id, value)","sourceCodeStart":645,"sourceCodeEnd":681,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/types/conversion.go#L645-L681","documentation":"ObjectValue for FloatID requires the Go value to be exactly float64. Any other numeric type (int, int64, float32) fails the type assertion and produces this error. The offending value is printed in the message.","triggerScenarios":"ObjectValue(types.FloatID, value) where value is int64, int, float32, or a non-number — e.g. passing an int64 result straight from an IntID Val into a FloatID ObjectValue.","commonSituations":"Cross-type copying of values between predicates; JSON numbers decoded into float32; hand-built mutation payloads with mismatched schema types.","solutions":["Convert explicitly: float64(v) before the call","Ensure the value's Go type matches the predicate's schema type (int64 for int schema, float64 for float schema)","Parse raw literals via types.ParseValue(types.FloatID, ...) so the resulting Val.Value is float64"],"exampleFix":"// before\ntypes.ObjectValue(types.FloatID, int64(7)) // error\n// after\ntypes.ObjectValue(types.FloatID, float64(7))","handlingStrategy":"type-guard","validationCode":"func isFloat64(v interface{}) bool { _, ok := v.(float64); return ok }\nif isFloat64(value) { types.ObjectValue(types.FloatID, value) } else { /* float64(v) first */ }","typeGuard":"func asFloat64(v interface{}) (float64, bool) {\n    switch n := v.(type) {\n    case float64: return n, true\n    case float32: return float64(n), true\n    case int64: return float64(n), true\n    }\n    return 0, false\n}","tryCatchPattern":null,"preventionTips":["Use float64 for all float values destined for FloatID predicates","Convert int64/float32 explicitly before ObjectValue","Align the Go value type with the predicate schema type at construction time"],"tags":["types","objectvalue","float64","type-mismatch"],"backgroundTag":"value-type-mismatch","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}