cayleygraph/cayley · error
No matching values for the item %#v in %#v
Error message
No matching values for the item %#v in %#v
What it means
In linkedql's JSON-LD pattern comparison (jsonld_util.go:61), the isomorphic function recursively compares a source JSON-LD value against a target value. When the source is a slice (ldSlice), every element of the target slice is checked for a structurally isomorphic match; if any source element has no match, this error is thrown. It means the pattern's array value does not correspond element-wise/structurally to the expected JSON-LD data.
Source
Thrown at query/linkedql/steps/jsonld_util.go:61
return fmt.Errorf("Expected \"%v\" but instead received \"%v\"", s, t)
}
return nil
case ldArray:
t, ok := target.(ldArray)
if !ok {
return fmt.Errorf("Expected multiple values but instead received the single value: %#v", target)
}
if len(s) != len(t) {
return fmt.Errorf("Expected %#v and %#v to have the same length", s, t)
}
items:
for _, i := range s {
for _, tI := range t {
if isomorphic(i, tI) == nil {
continue items
}
}
return fmt.Errorf("No matching values for the item %#v in %#v", i, t)
}
return nil
case ldMap:
t, ok := target.(ldMap)
if !ok {
return fmt.Errorf("Expected %#v to be a map or a slice with a single map but instead received %T", target, target)
}
for k, v := range s {
tV, _ := t[k]
err := isomorphic(v, tV)
if err != nil {
return err
}
}
}
return nil
}
View on GitHub (pinned to 81dcd7d73e)
Solutions
- Check each element of the source array against the target data for exact structural equality (properties, @id, @type).
- Fix typos in IRIs, @type names, or keys inside the array value of the pattern.
- If the element is legitimately optional, remove it from the pattern array or restructure the pattern.
- Log both %#v values from the error message to identify which element failed to match.
Example fix
// before
pattern := map[string]interface{}{"@type": []interface{}{"Preson"}} // typo
// after
pattern := map[string]interface{}{"@type": []interface{}{"Person"}} Defensive patterns
Strategy: validation
Validate before calling
func arrayElementsPresentIn(pattern []interface{}, target []interface{}) bool {
for _, p := range pattern {
found := false
for _, t := range target {
if reflect.DeepEqual(p, t) { found = true; break }
}
if !found { return false }
}
return true
} Type guard
func asLDMapSlice(v interface{}) ([]map[string]interface{}, bool) {
s, ok := v.([]interface{})
if !ok { return nil, false }
out := make([]map[string]interface{}, 0, len(s))
for _, e := range s {
m, ok := e.(map[string]interface{})
if !ok { return nil, false }
out = append(out, m)
}
return out, true
} Try / catch
if err := isomorphic(src, target); err != nil {
// err names the non-matching item in %#v; log and fall back to looser matching
log.Printf("pattern mismatch: %v", err)
} Prevention
- Validate JSON-LD patterns against your data model before matching
- Verify IRIs and @type names with a linter or constant definitions
- Log both compared values when a match fails to spot the exact element
When it happens
Trigger: Calling isomorphic (directly or via pattern parsing) with a source ldSlice whose element has no isomorphic counterpart in the target ldSlice, e.g. a pattern like {"@type": ["Person"]} compared against data lacking a matching entry.
Common situations: Writing LinkedQL JSON-LD patterns where an array of values (types, IRIs, nested objects) does not match any element in the document being matched; typos in IRIs or type names inside arrays.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Expected %#v to be a map or a slice with a single map but in
- Unexpected type for @id %T
- Pattern does not parse to any quad. `{}` is the only pattern
- must execute a IteratorStep or PathStep
- Not implemented: should tag all properties
AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06).
Data as JSON: /api/errors/c226aedcd0759c74.
Report an issue: GitHub.