{"record":{"id":"3fc5eb5d3cdfb152","repo":"cayleygraph/cayley","slug":"pattern-does-not-parse-to-any-quad-is-the-on","errorCode":null,"errorMessage":"Pattern does not parse to any quad. `{}` is the only pattern allowed to not parse to any quad","messagePattern":"Pattern does not parse to any quad\\. `(.+?)` is the only pattern allowed to not parse to any quad","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"query/linkedql/steps/match.go","lineNumber":160,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"Unexpected type for @id %T\", idString)\n\t\t}\n\t\tquads = append(quads, makeSingleEntityQuad(quad.IRI(idString)))\n\t}\n\treturn quads, nil\n}\n\nfunc parsePattern(pattern linkedql.GraphPattern, ns *voc.Namespaces) ([]quad.Quad, error) {\n\tcontextualizedPattern := contextualizePattern(pattern, ns)\n\tquads, err := quadsFromMap(contextualizedPattern)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tquads, err = normalizeQuads(quads, contextualizedPattern)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(quads) == 0 && len(pattern) != 0 {\n\t\treturn nil, fmt.Errorf(\"Pattern does not parse to any quad. `{}` is the only pattern allowed to not parse to any quad\")\n\t}\n\treturn quads, nil\n}\n\n// makeSingleEntityQuad creates a quad representing a propertyless entity. The\n// quad declares the entity is of type Resource, the base type of all entities\n// in RDF.\nfunc makeSingleEntityQuad(id quad.IRI) quad.Quad {\n\treturn quad.Quad{Subject: id, Predicate: quad.IRI(rdf.Type), Object: quad.IRI(rdfs.Resource)}\n}\n\nfunc isSingleEntityQuad(q quad.Quad) bool {\n\t// rdf:type rdfs:Resource is always true but not expressed in the graph.\n\t// it is used to specify an entity without specifying a property.\n\treturn q.Predicate == quad.IRI(rdf.Type) && q.Object == quad.IRI(rdfs.Resource)\n}\n","sourceCodeStart":142,"sourceCodeEnd":177,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/query/linkedql/steps/match.go#L142-L177","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\npattern := linkedql.GraphPattern{\"typ\": \"Person\"} // unrecognized key\n// after\npattern := linkedql.GraphPattern{\"@type\": \"http://xmlns.com/foaf/0.1/Person\"}","handlingStrategy":"validation","validationCode":"func validatePatternProducesQuads(pattern map[string]interface{}) error {\n  if len(pattern) == 0 { return nil }\n  if _, ok := pattern[\"@id\"]; ok { return nil }\n  if len(pattern) > 0 { return fmt.Errorf(\"pattern %v may produce no quads; only {} may be empty\", pattern) }\n  return nil\n}","typeGuard":"func isEmptyPattern(p map[string]interface{}) bool { return len(p) == 0 }","tryCatchPattern":"quads, err := parsePattern(pattern, ctx)\nif err != nil {\n  if strings.Contains(err.Error(), \"does not parse to any quad\") {\n    return fmt.Errorf(\"invalid pattern %v: check keys and spelling\", pattern)\n  }\n  return err\n}","preventionTips":["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"],"tags":["linkedql","pattern-matching","go"],"backgroundTag":"empty-result-set","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}