{"record":{"id":"02a4667e06d61be9","repo":"dgraph-io/dgraph","slug":"unknown-value-type-for-nquad-v","errorCode":null,"errorMessage":"Unknown value type for nquad: %+v","messagePattern":"Unknown value type for nquad: %\\+v","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dql/mutation.go","lineNumber":194,"sourceCode":"\n\tif sUid == 0 {\n\t\treturn nil, errors.Errorf(\"Subject should be > 0 for nquad: %+v\", nq)\n\t}\n\n\tswitch nq.valueType() {\n\tcase x.ValueUid:\n\t\toUid, err := toUid(nq.ObjectId, newToUid)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif oUid == 0 {\n\t\t\treturn nil, errors.Errorf(\"ObjectId should be > 0 for nquad: %+v\", nq)\n\t\t}\n\t\tedge = nq.CreateUidEdge(sUid, oUid)\n\tcase x.ValuePlain, x.ValueMulti:\n\t\tedge, err = nq.CreateValueEdge(sUid)\n\tdefault:\n\t\treturn &emptyEdge, errors.Errorf(\"Unknown value type for nquad: %+v\", nq)\n\t}\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn edge, nil\n}\n\nfunc copyValue(out *pb.DirectedEdge, nq NQuad) error {\n\tvar err error\n\tvar t types.TypeID\n\tif out.Value, t, err = byteVal(nq); err != nil {\n\t\treturn err\n\t}\n\tout.ValueType = t.Enum()\n\treturn nil\n}\n\nfunc (nq NQuad) valueType() x.ValueTypeInfo {","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dql/mutation.go#L176-L212","documentation":"ToEdgeUsing switches on nq.valueType() to decide whether to build a UID edge or a value edge. If the N-Quad's value type is none of the known kinds (ValueUid, ValuePlain, ValueMulti), the library cannot represent it as an edge and returns this error from the default branch.","triggerScenarios":"Passing a malformed or programmatically constructed api.NQuad to ToEdgeUsing whose ObjectId/value encoding does not map to any known ValueType — e.g. an NQuad built by hand with an unset or unsupported ValueType field.","commonSituations":"Constructing api.NQuad structs in Go instead of parsing RDF text (parser normally sets ValueType); version drift where a ValueType enum value isn't handled by this Dgraph version; corrupted intermediate representations from custom tooling.","solutions":["Build N-Quads via the RDF parser instead of hand-filling api.NQuad so ValueType is derived correctly","Print the offending nquad (%+v) and check its ValueType/ObjectValue fields against the supported x.Value* constants","Upgrade/align client and server versions so the ValueType enum matches what dql supports","If the value is a literal, ensure ObjectId is set (not empty) so valueType() classifies it as ValuePlain"],"exampleFix":"// before\nnq := api.NQuad{Subject: \"0x1\", Predicate: \"name\"} // no object/value set\n// after\nnq := api.NQuad{Subject: \"0x1\", Predicate: \"name\", ObjectId: \"0x2\"}","handlingStrategy":"validation","validationCode":"func knownValueType(nq *api.NQuad) bool {\n  switch nq.ValueType {\n  case api.NQuad_VALUE_UID, api.NQuad_VALUE_STRING, api.NQuad_VALUE_DATETIME, api.NQuad_VALUE_INT, api.NQuad_VALUE_FLOAT, api.NQuad_VALUE_BOOL:\n    return true\n  }\n  return nq.ObjectId != \"\" || nq.ObjectValue != nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer parsing RDF strings over hand-constructing api.NQuad structs","Keep client protobuf/ValueType enum versions in sync with the server","Set either ObjectId (edge) or ObjectValue (literal) on every N-Quad"],"tags":["dgraph","dql","mutation","value-type"],"backgroundTag":"unsupported-nquad-value-type","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}