dgraph-io/dgraph · error
JSON map is followed by illegal rune "%c"
Error message
JSON map is followed by illegal rune "%c"
What it means
GetIndexFactoryOptsFromSpec resolves the index factory by spec.Name, then extracts its Options. If no factory is registered under that name, it cannot produce Options and returns this error. It is the same registry-lookup failure as the create-spec variant, but on the options-extraction path.
Source
Thrown at chunker/chunk.go:228
// 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
for {
ch, err := jc.nextRune(r)
if err != nil {View on GitHub (pinned to 759e242be6)
Solutions
- Correct spec.Name to a registered factory name (verify via the factory registry).
- Regenerate/re-apply the schema using the index names supported by your Dgraph version.
- If options are optional in your flow, use GetIndexFactoryFromSpec first and skip when !found.
Example fix
// before
opts, err := tok.GetIndexFactoryOptsFromSpec(&pb.VectorIndexSpec{Name: "vector-hnsw"})
// after
if factory, found := tok.GetIndexFactoryFromSpec(spec); found {
opts, err = tok.GetIndexFactoryOptsFromSpec(spec)
} Defensive patterns
Strategy: validation
Validate before calling
if _, found := tok.GetIndexFactoryFromSpec(spec); found {
opts, err = tok.GetIndexFactoryOptsFromSpec(spec)
} Try / catch
opts, err := tok.GetIndexFactoryOptsFromSpec(spec)
if err != nil {
if _, found := tok.GetIndexFactoryFromSpec(spec); !found {
return nil, fmt.Errorf("factory %q not registered in this build", spec.Name)
}
return nil, err
} Prevention
- Check factory existence with GetIndexFactoryFromSpec before extracting options.
- Keep schema index names in sync with the Dgraph binary version.
- Add a startup smoke test that resolves all schema index specs.
When it happens
Trigger: Calling GetIndexFactoryOptsFromSpec with a *pb.VectorIndexSpec whose Name does not match any registered index factory.
Common situations: Vector index name typo in schema; reading a schema produced by a Dgraph version with different factory names; code referencing an experimental factory that was renamed.
Related errors
- illegal rune found "%c", expecting {
- Malformed JSON
- error creating indexer for %s: %w
- there are duplicates in existing data for predicate [%v].Ple
- unique validation failed to fetch schema for predicates %v
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/d2ee282994b07152.
Report an issue: GitHub.