cayleygraph/cayley · error
unknown quad format %q
Error message
unknown quad format %q
What it means
This error means QuadReaderFor could not resolve the quad serialization format for the given type string. The loader first tries registered format writers (via writerQuadTypes/format registry) and then falls back to quad.FormatByName(typ); if both return nil, the name is not a known quad format, so loading is aborted. It exists to fail fast on a misspelled or unsupported --format / configuration value before any data is read.
Source
Thrown at internal/load.go:102
switch typ {
case "cquad", "nquad": // legacy
qr = nquads.NewReader(r, false)
default:
var format *quad.Format
if typ == "" {
name := filepath.Base(path)
name = strings.TrimSuffix(name, ".gz")
name = strings.TrimSuffix(name, ".bz2")
format = quad.FormatByExt(filepath.Ext(name))
if format == nil {
typ = "nquads"
}
}
if format == nil {
format = quad.FormatByName(typ)
}
if format == nil {
err = fmt.Errorf("unknown quad format %q", typ)
} else if format.Reader == nil {
err = fmt.Errorf("decoding of %q is not supported", typ)
}
if err != nil {
if c != nil {
c.Close()
}
return nil, err
}
qr = format.Reader(r)
}
if c != nil {
return readCloser{ReadCloser: qr, close: c.Close}, nil
}
return qr, nil
}
// DecompressAndLoad will load or fetch a graph from the given path, decompressView on GitHub (pinned to 81dcd7d73e)
Solutions
- Check the format name against quad.RegisterFormat registrations (e.g. "nquads", "jsonld"); fix the spelling in the CLI flag or config.
- If the file extension drives detection, rename the file to the expected extension or pass the format explicitly.
- Run `cayley ` with the supported formats listed in the docs to confirm which names exist in your build.
- If the format genuinely does not exist, convert the data to nquads first (e.g. with a serializer) and load that.
Example fix
// before cayley load --format nquad data.nq // after cayley load --format nquads data.nq
Defensive patterns
Strategy: validation
Validate before calling
if quad.FormatByName(formatName) == nil {
return fmt.Errorf("unsupported quad format: %q (use nquads, jsonld, ...)", formatName)
}
_, err := internal.QuadReaderFor(ctx, path, formatName, compress)
Prevention
- Keep a list of valid format names from quad.RegisterFormat and validate CLI/config values against it.
- Let format be inferred from the file extension instead of hand-typing it.
- Test your load pipeline with a tiny sample file before large imports.
When it happens
Trigger: Calling internal.QuadReaderFor (directly or via internal.DecompressAndLoad from internal.Load, e.g. `cayley load`) with a file whose detected/derived typ string has no registered format: a misspelled format name like 'nquad' instead of 'nquads', or an unknown file extension, or passing a typ that quad.FormatByName does not recognize.
Common situations: Typo in the format flag or config (e.g. "nquad", "NQuads", "triples"); loading a file with an unrecognized extension; a Cayley build/version where a given format is not registered; scripts hard-coding a format string from another tool.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- decoding of %q is not supported
- ErrEmptyPath
- db: failed to load data: %v
- HTTP Request needed
- cannot count iterator without a valid context
AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06).
Data as JSON: /api/errors/7f0e6f36c6390b04.
Report an issue: GitHub.