{"record":{"id":"97bb69fb696001c8","repo":"dgraph-io/dgraph","slug":"if-predicate-subject-is-value-should-be-as-we","errorCode":null,"errorMessage":"if predicate/subject is *, value should be * as well","messagePattern":"if predicate/subject is \\*, value should be \\* as well","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"chunker/rdf_parser.go","lineNumber":142,"sourceCode":"\t\t\t\trnq.Predicate = x.Star\n\t\t\tdefault:\n\t\t\t\trnq.ObjectValue = &api.Value{Val: &api.Value_DefaultVal{DefaultVal: x.Star}}\n\t\t\t}\n\n\t\tcase itemLiteral:\n\t\t\tvar err error\n\t\t\toval, err = strconv.Unquote(item.Val)\n\t\t\tif err != nil {\n\t\t\t\treturn rnq, fmt.Errorf(\"while unquoting: %w\", err)\n\t\t\t}\n\t\t\tseenOval = true\n\n\t\tcase itemLanguage:\n\t\t\trnq.Lang = item.Val\n\n\t\tcase itemObjectType:\n\t\t\tif rnq.Predicate == x.Star || rnq.Subject == x.Star {\n\t\t\t\treturn rnq, errors.New(\"if predicate/subject is *, value should be * as well\")\n\t\t\t}\n\n\t\t\tval := strings.TrimFunc(item.Val, isSpaceRune)\n\t\t\t// TODO: Check if this condition is required.\n\t\t\tif val == \"*\" {\n\t\t\t\treturn rnq, errors.New(\"itemObject can't be *\")\n\t\t\t}\n\t\t\t// Lets find out the storage type from the type map.\n\t\t\tt, ok := typeMap[val]\n\t\t\tif !ok {\n\t\t\t\treturn rnq, fmt.Errorf(\"unrecognized rdf type %s\", val)\n\t\t\t}\n\t\t\tif oval == \"\" && t != types.StringID {\n\t\t\t\treturn rnq, errors.New(\"invalid ObjectValue\")\n\t\t\t}\n\t\t\tsrc := types.ValueForType(types.StringID)\n\t\t\tsrc.Value = []byte(oval)\n\t\t\t// if this is a password value dont re-encrypt. issue#2765","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/chunker/rdf_parser.go#L124-L160","documentation":"In ParseRDF (chunker/rdf_parser.go:142), a wildcard '*' is only allowed when used consistently for subject, predicate, and object (a full-line delete). If the object type (itemObjectType) is '*' while the predicate or subject is also '*', this specific guard rejects the combination expected to be uniform; here it fires when subject or predicate is Star but the value combination is inconsistent (e.g. typed object '*' with a real subject). It enforces that wildcard deletion syntax covers all three positions together.","triggerScenarios":"Calling Parse/ParseRDFs with an N-Quad like `* * \"*\" .` variants where the object position is '*' but subject/predicate are not also '*', or mixing '*' for subject/predicate with a typed object value.","commonSituations":"Hand-written deletion scripts attempting partial wildcard deletes (delete all objects of a predicate) using '*' in the object position, which the parser disallows unless the whole triple is '*'.","solutions":["Use '*' consistently for all three positions (`* * * .`) for full delete, or specify real values for subject/predicate/object.","To delete all edges of a predicate, run a query to fetch UIDs and emit explicit triples with '*' only in the object position via a mutation, not mixed-wildcard N-Quads.","Review Dgraph's delete syntax docs and rewrite the line to conform."],"exampleFix":"// before\n* <name> \"*\" .\n// after (full delete)\n* * * .\n// or targeted delete\n<0x1> <name> * .","handlingStrategy":"validation","validationCode":"func wildcardConsistent(fields []string) error {\n\tn := 0\n\tfor _, f := range fields {\n\t\tif f == \"*\" {\n\t\t\tn++\n\t\t}\n\t}\n\tif n != 0 && n != 3 {\n\t\treturn errors.New(\"wildcard must appear in all of subject/predicate/object or none\")\n\t}\n\treturn nil\n}","typeGuard":"func isFullWildcardDelete(subject, predicate, object string) bool {\n\treturn subject == \"*\" && predicate == \"*\" && object == \"*\"\n}","tryCatchPattern":"nq, err := chunker.ParseRDF(line, op)\nif err != nil && strings.Contains(err.Error(), \"value should be * as well\") {\n\t// rewrite the line: either all wildcards or all concrete values\n}","preventionTips":["Only use '*' as a full triple wildcard for delete-all","For targeted deletes, keep subject and predicate concrete and use '*' only in the object position per Dgraph delete syntax","Lint N-Quad deletion scripts for mixed wildcard usage"],"tags":["rdf-parser","wildcard","deletion","dgraph"],"backgroundTag":"invalid-wildcard-nquad","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}