{"record":{"id":"b7c81a7b1e32f49f","repo":"dgraph-io/dgraph","slug":"input-for-predicate-q-of-type-vector-is-not-vecto","errorCode":null,"errorMessage":"Input for predicate %q of type vector is not vector. Did you forget to add quotes before []?. Edge: %v","messagePattern":"Input for predicate %q of type vector is not vector\\. Did you forget to add quotes before \\[\\]\\?\\. Edge: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/mutation.go","lineNumber":543,"sourceCode":"\tcase edge.Lang != \"\" && !su.GetLang():\n\t\treturn errors.Errorf(\"Attr: [%v] should have @lang directive in schema to mutate edge: [%v]\",\n\t\t\tx.ParseAttr(edge.Attr), edge)\n\n\tcase !schemaType.IsScalar() && !storageType.IsScalar():\n\t\treturn nil\n\n\tcase !schemaType.IsScalar() && storageType.IsScalar():\n\t\treturn errors.Errorf(\"Input for predicate %q of type uid is scalar. Edge: %v\",\n\t\t\tx.ParseAttr(edge.Attr), edge)\n\n\tcase schemaType.IsScalar() && !storageType.IsScalar():\n\t\treturn errors.Errorf(\"Input for predicate %q of type scalar is uid. Edge: %v\",\n\t\t\tx.ParseAttr(edge.Attr), edge)\n\n\tcase schemaType == types.TypeID(pb.Posting_VFLOAT):\n\t\tif !(storageType == types.TypeID(pb.Posting_VFLOAT) || storageType == types.TypeID(pb.Posting_STRING) ||\n\t\t\tstorageType == types.TypeID(pb.Posting_DEFAULT)) {\n\t\t\treturn errors.Errorf(\"Input for predicate %q of type vector is not vector.\"+\n\t\t\t\t\" Did you forget to add quotes before []?. Edge: %v\", x.ParseAttr(edge.Attr), edge)\n\t\t}\n\n\t// The suggested storage type matches the schema, OK! (Nothing to do ...)\n\tcase storageType == schemaType && schemaType != types.DefaultID:\n\t\treturn nil\n\n\t// We accept the storage type iff we don't have a schema type and a storage type is specified.\n\tcase schemaType == types.DefaultID:\n\t\tschemaType = storageType\n\t}\n\n\tvar (\n\t\tdst types.Val\n\t\terr error\n\t)\n\n\tsrc := types.Val{Tid: types.TypeID(edge.ValueType), Value: edge.Value}","sourceCodeStart":525,"sourceCodeEnd":561,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/mutation.go#L525-L561","documentation":"For predicates of type float32vector, the storage value must itself be a vector (or a string/default value, which are accepted intermediate forms). If the edge's storage type is e.g. int, float, bool, etc., ValidateAndConvert rejects it and hints that the user may have written the vector literal without the quotes required in RDF syntax.","triggerScenarios":"Mutating a float32vector predicate with a non-vector value, classically writing `<0x1> <emb> [0.1,0.2,0.3] .` unquoted in RDF (so it parses as something other than a string-encoded vector) instead of `<0x1> <emb> \"[0.1,0.2,0.3]\"^^<xs:float32vector> .`.","commonSituations":"Dropping quotes around the JSON-style array in raw RDF; using a JSON mutation client that sends numbers individually; scripting bulk vector loads that format values incorrectly.","solutions":["Quote the vector and type it: `\"[0.1,0.2,0.3]\"^^<xs:float32vector>` in RDF, or pass a proper JSON array in JSON mutations.","Verify the value is a flat numeric array with the dimensionality expected by the HNSW index.","Check the client serialization so arrays are sent as arrays, not scalars."],"exampleFix":"// before (fails)\n<0x1> <emb> [0.1,0.2,0.3] .\n\n// after\n<0x1> <emb> \"[0.1,0.2,0.3]\"^^<xs:float32vector> .","handlingStrategy":"validation","validationCode":"function assertVectorValue(pred, value) {\n  if (!pred.endsWith('float32vector')) return\n  const ok = Array.isArray(value) && value.every(n => typeof n === 'number' && Number.isFinite(n))\n  if (!ok) throw new Error(`${pred} requires a numeric array vector, got ${JSON.stringify(value)}`)\n}","typeGuard":"function isFloatVector(v) {\n  return Array.isArray(v) && v.length > 0 && v.every(n => typeof n === 'number')\n}","tryCatchPattern":"try {\n  await txn.mutate(mu)\n} catch (e) {\n  if (String(e).includes('of type vector is not vector')) {\n    // re-send the value as a quoted, typed float32vector literal\n  }\n}","preventionTips":["In RDF, always quote vector literals: \"[0.1,0.2]\"^^<xs:float32vector>.","Validate array dimensions and numeric elements before bulk vector loads.","Prefer JSON mutations so arrays serialize natively as arrays."],"tags":["dgraph","mutation","vector","type-mismatch"],"backgroundTag":"type-mismatch-mutation","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}