weaviate/weaviate · error
nested path %q: empty sub-property path
Error message
nested path %q: empty sub-property path
What it means
This is walkPath's loop-exit fallback. The for-loop returns on the final segment (leaf) or errors earlier, so reaching the statement after the loop means the segments slice was empty from the start — the path had only the root segment's remainder of zero sub-segments. It is a defensive guard indicating the caller passed an effectively empty sub-path.
Source
Thrown at entities/filters/nested/path.go:282
dt := schema.DataType(np.DataType[0])
if seg.HasIndex {
if _, ok := schema.IsArrayType(dt); !ok {
return nil, fmt.Errorf(
"nested path %q: sub-property %q is of type %q — [N] indexing requires an array type",
fullPath, seg.Name, dt)
}
}
if i == len(segs)-1 {
return np, nil
}
if !schema.IsNested(dt) {
return nil, fmt.Errorf(
"nested path %q: sub-property %q must be object or object[], got %q",
fullPath, seg.Name, dt)
}
props = np.NestedProperties
}
return nil, fmt.Errorf("nested path %q: empty sub-property path", fullPath)
}
View on GitHub (pinned to 75aa4b6d11)
Solutions
- Never call walkPath directly; use ResolveLeaf/ResolveLeafFromRoot which pre-validate segment count
- Validate the path string is non-empty and contains at least root.sub before resolution
- Treat this error as an internal invariant violation and log the full path for debugging
Example fix
// before — direct call with empty sub-segments np, err := walkPath(rootProp.NestedProperties, nil, path) // after — go through the public resolver np, err := nested.ResolveLeafFromRoot(rootProp, path)
Defensive patterns
Strategy: validation
Validate before calling
if path == "" { return fmt.Errorf("empty nested path") }
segs := nested.ParseSegments(path)
if len(segs) == 0 { return fmt.Errorf("path %q parsed to zero segments", path) } Prevention
- Use only the exported resolvers (ResolveLeaf/ResolveLeafFromRoot)
- Reject empty or whitespace-only path strings early
- Treat this error as an invariant violation; log full context
When it happens
Trigger: Calling ResolveLeafFromRoot with a path that parses to segments such that segs[1:] passed to walkPath is empty — practically only possible via direct walkPath invocation or a degenerate/empty path string that still passes the earlier length checks.
Common situations: Almost exclusively seen from direct walkPath calls in tests or internal refactors; an empty path string slipping through upstream validation.
Related errors
- ResolveLeafFromRoot: root property is nil or has no datatype
- property %q is of type %q — [N] indexing requires an array t
- property %q has no sub-property segments
- nested path %q: sub-property %q not found
- nested path %q: sub-property %q is of type %q — [N] indexing
AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04).
Data as JSON: /api/errors/8f1b1c81f9f48841.
Report an issue: GitHub.