dgraph-io/dgraph · error

if predicate/subject is *, value should be * as well

Error message

if predicate/subject is *, value should be * as well

What it means

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.

Source

Thrown at chunker/rdf_parser.go:142

				rnq.Predicate = x.Star
			default:
				rnq.ObjectValue = &api.Value{Val: &api.Value_DefaultVal{DefaultVal: x.Star}}
			}

		case itemLiteral:
			var err error
			oval, err = strconv.Unquote(item.Val)
			if err != nil {
				return rnq, fmt.Errorf("while unquoting: %w", err)
			}
			seenOval = true

		case itemLanguage:
			rnq.Lang = item.Val

		case itemObjectType:
			if rnq.Predicate == x.Star || rnq.Subject == x.Star {
				return rnq, errors.New("if predicate/subject is *, value should be * as well")
			}

			val := strings.TrimFunc(item.Val, isSpaceRune)
			// TODO: Check if this condition is required.
			if val == "*" {
				return rnq, errors.New("itemObject can't be *")
			}
			// Lets find out the storage type from the type map.
			t, ok := typeMap[val]
			if !ok {
				return rnq, fmt.Errorf("unrecognized rdf type %s", val)
			}
			if oval == "" && t != types.StringID {
				return rnq, errors.New("invalid ObjectValue")
			}
			src := types.ValueForType(types.StringID)
			src.Value = []byte(oval)
			// if this is a password value dont re-encrypt. issue#2765

View on GitHub (pinned to 759e242be6)

Solutions

  1. Use '*' consistently for all three positions (`* * * .`) for full delete, or specify real values for subject/predicate/object.
  2. 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.
  3. Review Dgraph's delete syntax docs and rewrite the line to conform.

Example fix

// before
* <name> "*" .
// after (full delete)
* * * .
// or targeted delete
<0x1> <name> * .
Defensive patterns

Strategy: validation

Validate before calling

func wildcardConsistent(fields []string) error {
	n := 0
	for _, f := range fields {
		if f == "*" {
			n++
		}
	}
	if n != 0 && n != 3 {
		return errors.New("wildcard must appear in all of subject/predicate/object or none")
	}
	return nil
}

Type guard

func isFullWildcardDelete(subject, predicate, object string) bool {
	return subject == "*" && predicate == "*" && object == "*"
}

Try / catch

nq, err := chunker.ParseRDF(line, op)
if err != nil && strings.Contains(err.Error(), "value should be * as well") {
	// rewrite the line: either all wildcards or all concrete values
}

Prevention

When it happens

Trigger: 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.

Common situations: 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 '*'.

Related errors


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