dgraph-io/dgraph · error
Input for predicate %q of type vector is not vector. Did you
Error message
Input for predicate %q of type vector is not vector. Did you forget to add quotes before []?. Edge: %v
What it means
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.
Source
Thrown at worker/mutation.go:543
case edge.Lang != "" && !su.GetLang():
return errors.Errorf("Attr: [%v] should have @lang directive in schema to mutate edge: [%v]",
x.ParseAttr(edge.Attr), edge)
case !schemaType.IsScalar() && !storageType.IsScalar():
return nil
case !schemaType.IsScalar() && storageType.IsScalar():
return errors.Errorf("Input for predicate %q of type uid is scalar. Edge: %v",
x.ParseAttr(edge.Attr), edge)
case schemaType.IsScalar() && !storageType.IsScalar():
return errors.Errorf("Input for predicate %q of type scalar is uid. Edge: %v",
x.ParseAttr(edge.Attr), edge)
case schemaType == types.TypeID(pb.Posting_VFLOAT):
if !(storageType == types.TypeID(pb.Posting_VFLOAT) || storageType == types.TypeID(pb.Posting_STRING) ||
storageType == types.TypeID(pb.Posting_DEFAULT)) {
return errors.Errorf("Input for predicate %q of type vector is not vector."+
" Did you forget to add quotes before []?. Edge: %v", x.ParseAttr(edge.Attr), edge)
}
// The suggested storage type matches the schema, OK! (Nothing to do ...)
case storageType == schemaType && schemaType != types.DefaultID:
return nil
// We accept the storage type iff we don't have a schema type and a storage type is specified.
case schemaType == types.DefaultID:
schemaType = storageType
}
var (
dst types.Val
err error
)
src := types.Val{Tid: types.TypeID(edge.ValueType), Value: edge.Value}View on GitHub (pinned to 759e242be6)
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.
Example fix
// before (fails) <0x1> <emb> [0.1,0.2,0.3] . // after <0x1> <emb> "[0.1,0.2,0.3]"^^<xs:float32vector> .
Defensive patterns
Strategy: validation
Validate before calling
function assertVectorValue(pred, value) {
if (!pred.endsWith('float32vector')) return
const ok = Array.isArray(value) && value.every(n => typeof n === 'number' && Number.isFinite(n))
if (!ok) throw new Error(`${pred} requires a numeric array vector, got ${JSON.stringify(value)}`)
} Type guard
function isFloatVector(v) {
return Array.isArray(v) && v.length > 0 && v.every(n => typeof n === 'number')
} Try / catch
try {
await txn.mutate(mu)
} catch (e) {
if (String(e).includes('of type vector is not vector')) {
// re-send the value as a quoted, typed float32vector literal
}
} Prevention
- 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.
When it happens
Trigger: 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> .`.
Common situations: 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.
Related errors
- Left and right arguments must match
- Input for predicate %q of type uid is scalar. Edge: %v
- Input for predicate %q of type scalar is uid. Edge: %v
- UID must be present and non-zero while deleting edges
- facet value can only be string/number/bool
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/b7c81a7b1e32f49f.
Report an issue: GitHub.