{"record":{"id":"42b140229edf983f","repo":"dgraph-io/dgraph","slug":"expected-a-float32vector-but-got-v","errorCode":null,"errorMessage":"Expected a float32vector but got %v","messagePattern":"Expected a float32vector but got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dql/parser.go","lineNumber":352,"sourceCode":"\t\t\t\t\tValue: i,\n\t\t\t\t}, nil\n\t\t\t}\n\t\t}\n\tcase \"bool\":\n\t\t{\n\t\t\tif i, err := strconv.ParseBool(v.Value); err != nil {\n\t\t\t\treturn types.Val{}, errors.Wrapf(err, \"Expected a bool but got %v\", v.Value)\n\t\t\t} else {\n\t\t\t\treturn types.Val{\n\t\t\t\t\tTid:   types.BoolID,\n\t\t\t\t\tValue: i,\n\t\t\t\t}, nil\n\t\t\t}\n\t\t}\n\tcase \"float32vector\":\n\t\t{\n\t\t\tif i, err := types.ParseVFloat(v.Value); err != nil {\n\t\t\t\treturn types.Val{}, errors.Wrapf(err, \"Expected a float32vector but got %v\", v.Value)\n\t\t\t} else {\n\t\t\t\treturn types.Val{\n\t\t\t\t\tTid:   types.VFloatID,\n\t\t\t\t\tValue: i,\n\t\t\t\t}, nil\n\t\t\t}\n\t\t}\n\tcase \"string\": // Value is a valid string. No checks required.\n\t\treturn types.Val{\n\t\t\tTid:   types.StringID,\n\t\t\tValue: v.Value,\n\t\t}, nil\n\tdefault:\n\t\treturn types.Val{}, errors.Errorf(\"Type %q not supported\", typ)\n\t}\n}\n\nfunc checkValueType(vm varMap) error {","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dql/parser.go#L334-L370","documentation":"parseValue parses variables of type \"float32vector\" using types.ParseVFloat, which converts a bracketed list of numbers into a []float32 (used for vector/predicate search). If the string isn't a well-formed vector of floats, the error is wrapped with 'Expected a float32vector but got %v'.","triggerScenarios":"Passing a variable with Type \"float32vector\" whose Value is not a parseable float vector — e.g. \"[0.1, 0.2\" (unclosed bracket), \"[a, b]\" (non-numeric elements), or a plain number without brackets.","commonSituations":"Embedding/similarity-search workloads where embeddings are serialized incorrectly (wrong separator, JSON array with mismatched format); truncating large vectors when building query strings; clients sending nested arrays or comma strings without brackets.","solutions":["Serialize the vector as a bracketed comma-separated float list, e.g. \"[0.1,0.2,0.3]\"","Verify every element parses as a float and brackets are balanced before submitting","Re-encode the embedding on the client from the []float32 source instead of hand-formatting strings","Check that the vector wasn't truncated or corrupted by logging/size limits in your pipeline"],"exampleFix":"// before\nvars := map[string]string{\"$vec\": \"0.1, 0.2, 0.3\"}\n// after\nvars := map[string]string{\"$vec\": \"[0.1, 0.2, 0.3]\"}","handlingStrategy":"validation","validationCode":"func validVFloat(s string) bool {\n  s = strings.TrimSpace(s)\n  if !strings.HasPrefix(s, \"[\") || !strings.HasSuffix(s, \"]\") { return false }\n  inner := strings.Trim(s, \"[]\")\n  if inner == \"\" { return true }\n  for _, part := range strings.Split(inner, \",\") {\n    if _, err := strconv.ParseFloat(strings.TrimSpace(part), 32); err != nil { return false }\n  }\n  return true\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always serialize vectors as bracketed comma-separated float lists","Generate vector strings from []float32 programmatically, never by hand","Watch for truncation of long embedding strings in logs/serialization pipelines"],"tags":["dgraph","dql","variables","type-parsing","vector"],"backgroundTag":"query-variable-type-mismatch","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}