larksuite/cli · error
shape has no applicable variant
Error message
shape has no applicable variant
What it means
combineResolvedShapes merges the shapes collected after resolving a pointer through a oneOf shape: variants that are null-typed are skipped, and if every variant is null (or the list is empty) there is no applicable non-null variant to continue traversal with, so the library errors instead of producing an empty shape.
Source
Thrown at shortcuts/common/typed_compile_contract.go:172
if _, null := variant.(typedNullShape); null {
continue
}
field, err := resolveShapeField(variant, name)
if err != nil {
return nil, err
}
resolved = append(resolved, field)
}
return combineResolvedShapes(resolved)
default:
return nil, fmt.Errorf("segment %q traverses non-object shape", name)
}
}
func combineResolvedShapes(shapes []typedValueShape) (typedValueShape, error) {
switch len(shapes) {
case 0:
return nil, fmt.Errorf("shape has no applicable variant")
case 1:
return shapes[0], nil
default:
return typedOneOfShape{Variants: shapes}, nil
}
}
func shapeAsObject(shape typedValueShape) (typedObjectShape, bool) {
if object, ok := shape.(typedObjectShape); ok {
return object, true
}
if one, ok := shape.(typedOneOfShape); ok {
var combined typedObjectShape
found := false
for _, variant := range one.Variants {
if _, null := variant.(typedNullShape); null {
continue
}View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Add a non-null variant to the oneOf shape so traversal has a concrete object to descend into.
- Point the override Path at a different field whose shape has applicable variants.
- If null is the only valid value, override the parent field directly with null instead of traversing beneath it.
Example fix
// before
Shape: OneOf{Variants: []Shape{Null{}}} with Path "/union/field"
// after
Shape: OneOf{Variants: []Shape{Null{}, Object{Fields: ...}}} with Path "/union/field" Defensive patterns
Strategy: validation
Validate before calling
// before pointing into a oneOf field, confirm it has a non-null variant
func hasNonNullVariant(v unionShape) bool {
for _, x := range v.Variants { if _, isNull := x.(nullShape); !isNull { return true } }
return false
} Type guard
func hasNonNullVariant(v unionShape) bool {
for _, x := range v.Variants {
if _, isNull := x.(nullShape); !isNull { return true }
}
return false
} Prevention
- Always include at least one concrete variant in unions you traverse into
- Override the union field itself rather than descending into null-only unions
- Document union shapes so authors know which fields are traversable
When it happens
Trigger: resolveShapePointer/resolveShapeField traversing into a oneOf shape where all variants are typedNullShape, e.g. an override Path pointing through a field declared as oneOf with only null variants, or an explicit Shape pointer into such a union.
Common situations: Defining a union shape that only permits null and then trying to override a nested field under it; mis-wiring variant shapes so all resolve to null; metadata-driven shapes where variants were filtered out upstream.
Related errors
- field %q does not exist
- segment %q traverses non-object shape
- %s does not match any allowed shape
- segment %q has invalid RFC 6901 escaping
- value is not JSON-encodable: %w
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/8af3719ab062e653.
Report an issue: GitHub.