{"record":{"id":"7443abbeef27798c","repo":"larksuite/cli","slug":"variant-d-w","errorCode":null,"errorMessage":"variant %d: %w","messagePattern":"variant (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_shape.go","lineNumber":129,"sourceCode":"\t\t\t}\n\t\t\tfields[index] = typedValueField{\n\t\t\t\tName: field.Name, Description: field.Description, Required: field.Required, Shape: fieldShape,\n\t\t\t}\n\t\t}\n\t\tadditional, err := lowerAuthoringShape(value.AdditionalPropertiesShape)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn typedObjectShape{\n\t\t\tFields: fields, AdditionalProperties: value.AdditionalProperties,\n\t\t\tAdditionalPropertiesShape: additional,\n\t\t}, nil\n\tcase command.OneOfShape:\n\t\tvariants := make([]typedValueShape, len(value.Variants))\n\t\tfor index, variant := range value.Variants {\n\t\t\tlowered, err := lowerAuthoringShape(variant)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"variant %d: %w\", index, err)\n\t\t\t}\n\t\t\tvariants[index] = lowered\n\t\t}\n\t\treturn typedOneOfShape{Variants: variants}, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported public shape %T\", shape)\n\t}\n}\n","sourceCodeStart":111,"sourceCodeEnd":138,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_shape.go#L111-L138","documentation":"When lowering a OneOfShape, each variant is itself lowered recursively; this wrapper prefixes any nested failure with the variant index (variant %d) so nested diagnostics like 'field \"a\": unsupported public shape X' can be traced to the exact variant. It identifies which arm of a one-of declaration is malformed.","triggerScenarios":"A OneOfShape whose Variants slice contains an entry (or a nested object inside it) holding an unsupported/custom shape type or a typed-nil shape, causing the recursive lowerAuthoringShape call to fail.","commonSituations":"Building polymorphic inputs (e.g. user vs. open_id vs. union_id resolvers) where one variant was authored with the wrong shape type; refactors that renamed or replaced a shape type but missed one variant.","solutions":["Use the variant index in the error to find the bad Variants[i] entry.","Lower into the chain: the wrapped error names the nested field/type that is actually unsupported; fix that concrete shape.","Ensure every variant uses documented command.*Shape types only."],"exampleFix":"// before\ncommand.OneOfShape{Variants: []command.ValueShape{command.StringShape{}, rawMapShape{}}}\n// after\ncommand.OneOfShape{Variants: []command.ValueShape{command.StringShape{}, command.ObjectShape{Fields: ...}}}","handlingStrategy":"validation","validationCode":"for i, v := range oneOf.Variants {\n    if !isSupportedShape(v) {\n        return fmt.Errorf(\"variant %d: unsupported shape %T\", i, v)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run compileData on input definitions in tests to surface variant errors at build time.","Keep one-of variants uniform: build each variant with the same helper so a bad type cannot slip into one arm.","After renaming/replacing shape types, grep for the old type across all Variants slices."],"tags":["go","schema","typed-input","oneof","shape-lowering"],"backgroundTag":"unsupported-shape-type","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"}