{"record":{"id":"8af3719ab062e653","repo":"larksuite/cli","slug":"shape-has-no-applicable-variant","errorCode":null,"errorMessage":"shape has no applicable variant","messagePattern":"shape has no applicable variant","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_contract.go","lineNumber":172,"sourceCode":"\t\t\tif _, null := variant.(typedNullShape); null {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfield, err := resolveShapeField(variant, name)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tresolved = append(resolved, field)\n\t\t}\n\t\treturn combineResolvedShapes(resolved)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"segment %q traverses non-object shape\", name)\n\t}\n}\n\nfunc combineResolvedShapes(shapes []typedValueShape) (typedValueShape, error) {\n\tswitch len(shapes) {\n\tcase 0:\n\t\treturn nil, fmt.Errorf(\"shape has no applicable variant\")\n\tcase 1:\n\t\treturn shapes[0], nil\n\tdefault:\n\t\treturn typedOneOfShape{Variants: shapes}, nil\n\t}\n}\n\nfunc shapeAsObject(shape typedValueShape) (typedObjectShape, bool) {\n\tif object, ok := shape.(typedObjectShape); ok {\n\t\treturn object, true\n\t}\n\tif one, ok := shape.(typedOneOfShape); ok {\n\t\tvar combined typedObjectShape\n\t\tfound := false\n\t\tfor _, variant := range one.Variants {\n\t\t\tif _, null := variant.(typedNullShape); null {\n\t\t\t\tcontinue\n\t\t\t}","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_contract.go#L154-L190","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nShape: OneOf{Variants: []Shape{Null{}}} with Path \"/union/field\"\n// after\nShape: OneOf{Variants: []Shape{Null{}, Object{Fields: ...}}} with Path \"/union/field\"","handlingStrategy":"validation","validationCode":"// before pointing into a oneOf field, confirm it has a non-null variant\nfunc hasNonNullVariant(v unionShape) bool {\n  for _, x := range v.Variants { if _, isNull := x.(nullShape); !isNull { return true } }\n  return false\n}","typeGuard":"func hasNonNullVariant(v unionShape) bool {\n  for _, x := range v.Variants {\n    if _, isNull := x.(nullShape); !isNull { return true }\n  }\n  return false\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["oneof","shape-traversal","union-type","shortcuts"],"backgroundTag":"no-applicable-variant","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}