cayleygraph/cayley · error
Pattern does not parse to any quad. `{}` is the only pattern
Error message
Pattern does not parse to any quad. `{}` is the only pattern allowed to not parse to any quad What it means
parsePattern in match.go:160 requires that a pattern's fields translate into at least one quad. After contextualizing and normalizing, if the resulting quad list is empty while the original pattern map was non-empty, this error is thrown: only the literally empty pattern {} is allowed to yield no quads. It means the pattern contained keys the parser could not turn into any quad.
Source
Thrown at query/linkedql/steps/match.go:160
return nil, fmt.Errorf("Unexpected type for @id %T", idString)
}
quads = append(quads, makeSingleEntityQuad(quad.IRI(idString)))
}
return quads, nil
}
func parsePattern(pattern linkedql.GraphPattern, ns *voc.Namespaces) ([]quad.Quad, error) {
contextualizedPattern := contextualizePattern(pattern, ns)
quads, err := quadsFromMap(contextualizedPattern)
if err != nil {
return nil, err
}
quads, err = normalizeQuads(quads, contextualizedPattern)
if err != nil {
return nil, err
}
if len(quads) == 0 && len(pattern) != 0 {
return nil, fmt.Errorf("Pattern does not parse to any quad. `{}` is the only pattern allowed to not parse to any quad")
}
return quads, nil
}
// makeSingleEntityQuad creates a quad representing a propertyless entity. The
// quad declares the entity is of type Resource, the base type of all entities
// in RDF.
func makeSingleEntityQuad(id quad.IRI) quad.Quad {
return quad.Quad{Subject: id, Predicate: quad.IRI(rdf.Type), Object: quad.IRI(rdfs.Resource)}
}
func isSingleEntityQuad(q quad.Quad) bool {
// rdf:type rdfs:Resource is always true but not expressed in the graph.
// it is used to specify an entity without specifying a property.
return q.Predicate == quad.IRI(rdf.Type) && q.Object == quad.IRI(rdfs.Resource)
}
View on GitHub (pinned to 81dcd7d73e)
Solutions
- Verify pattern keys are recognized (e.g. @id, @type, valid property IRIs) and correctly spelled.
- If an empty match is intended, use the empty pattern {}.
- Add at least one field that translates to a quad, or supply a string "@id" so normalizeQuads can synthesize one.
- Inspect the contextualized pattern to see which fields were dropped during normalization.
Example fix
// before
pattern := linkedql.GraphPattern{"typ": "Person"} // unrecognized key
// after
pattern := linkedql.GraphPattern{"@type": "http://xmlns.com/foaf/0.1/Person"} Defensive patterns
Strategy: validation
Validate before calling
func validatePatternProducesQuads(pattern map[string]interface{}) error {
if len(pattern) == 0 { return nil }
if _, ok := pattern["@id"]; ok { return nil }
if len(pattern) > 0 { return fmt.Errorf("pattern %v may produce no quads; only {} may be empty", pattern) }
return nil
} Type guard
func isEmptyPattern(p map[string]interface{}) bool { return len(p) == 0 } Try / catch
quads, err := parsePattern(pattern, ctx)
if err != nil {
if strings.Contains(err.Error(), "does not parse to any quad") {
return fmt.Errorf("invalid pattern %v: check keys and spelling", pattern)
}
return err
} Prevention
- Use only recognized pattern keys (@id, @type, valid property IRIs)
- Use {} explicitly when an empty match is intended
- Test each pattern against parsePattern in unit tests before deploying queries
When it happens
Trigger: Calling Match.BuildPath / parsePattern with a non-empty pattern whose keys/values (other than a usable "@id") produce zero quads, e.g. only unknown or untranslatable keys.
Common situations: Typos in pattern keys (e.g. "@typ" instead of "@type"), patterns containing only contextual keys that get stripped, or copying patterns between API versions with changed key names.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- No matching values for the item %#v in %#v
- must execute a IteratorStep or PathStep
- Expected %#v to be a map or a slice with a single map but in
- Unexpected type for @id %T
- Not implemented: should tag all properties
AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06).
Data as JSON: /api/errors/3fc5eb5d3cdfb152.
Report an issue: GitHub.