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

  1. 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.
  2. Verify the value is a flat numeric array with the dimensionality expected by the HNSW index.
  3. 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

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


AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01). Data as JSON: /api/errors/b7c81a7b1e32f49f. Report an issue: GitHub.