dgraph-io/dgraph · error

illegal rune found "%c", expecting {

Error message

illegal rune found "%c", expecting {

What it means

GetFactoryCreateSpecFromSpec looks up the registered index factory matching the VectorIndexSpec's Name. When no factory with that name exists in the registry, the spec cannot be turned into a FactoryCreateSpec, so the library aborts. This typically means the predicate's index type in the schema references a tokenizer/index factory Dgraph does not know about.

Source

Thrown at chunker/chunk.go:225

			if !jc.inList {
				return nil, errors.New("JSON map is followed by an extraneous ]")
			}

			// validate that there are no more non-space chars after the ]
			if slurpSpace(r) != io.EOF {
				return nil, errors.New("not all of JSON file consumed")
			}

			if _, err := out.WriteRune(']'); err != nil {
				return nil, err
			}
			return out, io.EOF
		}

		// In the non-termination cases, ensure at least one map has been consumed, and
		// the only allowed char after the map is ",".
		if out.Len() == 1 { // 1 represents the [ inserted before the for loop
			return nil, fmt.Errorf("illegal rune found \"%c\", expecting {", ch)
		}
		if ch != ',' {
			return nil, fmt.Errorf("JSON map is followed by illegal rune \"%c\"", ch)
		}
	}
	if _, err := out.WriteRune(']'); err != nil {
		return nil, err
	}
	return out, nil
}

// consumeMap consumes the next map from the reader, and stores the result into the buffer out.
// After ignoring spaces, if the reader does not begin with {, no rune will be consumed
// from the reader.
func (jc *jsonChunker) consumeMap(r *bufio.Reader, out *bytes.Buffer) error {
	// Just find the matching closing brace. Let the JSON-to-nquad parser in the mapper worry
	// about whether everything in between is valid JSON or not.
	depth := 0

View on GitHub (pinned to 759e242be6)

Solutions

  1. Check spec.Name against the registered index factories and fix the schema's index name (typo/case).
  2. Align the Dgraph binary version with the schema: upgrade or downgrade so the factory exists.
  3. If a custom factory was expected, register it before calling GetFactoryCreateSpecFromSpec.
  4. Drop and re-apply the offending predicate schema with a supported index type.

Example fix

// before
spec := &pb.VectorIndexSpec{Name: "hnsw-cosine"}
spec2, err := tok.GetFactoryCreateSpecFromSpec(spec)
// after
spec := &pb.VectorIndexSpec{Name: "hnsw"} // use a registered factory name
spec2, err := tok.GetFactoryCreateSpecFromSpec(spec)
Defensive patterns

Strategy: validation

Validate before calling

if _, found := tok.GetIndexFactoryFromSpec(spec); !found {
    return fmt.Errorf("unsupported vector index: %q", spec.Name)
}
// safe: tok.GetFactoryCreateSpecFromSpec(spec)

Try / catch

spec2, err := tok.GetFactoryCreateSpecFromSpec(spec)
if err != nil && strings.Contains(err.Error(), "cannot find index factory named") {
    // fall back to a supported factory or surface a schema-fix hint
}

Prevention

When it happens

Trigger: Calling GetFactoryCreateSpecFromSpec (directly or via getOrCreateIndexer, rebuildTokIndex, needsTokIndexRebuild, needsVectorIndexEdgesRebuild, FactoryCreateSpec) with a *pb.VectorIndexSpec whose Name is not a registered index factory name.

Common situations: Schema JSON altered by hand with a typo in the index name; schema written by a newer/older Dgraph version using an index factory removed or renamed; a dropped custom index plugin not registered at startup.

Related errors


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