{"record":{"id":"d4e40a2f5eaeecf5","repo":"larksuite/cli","slug":"provided-type-has-invalid-set-field","errorCode":null,"errorMessage":"Provided type has invalid Set field","messagePattern":"Provided type has invalid Set field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":198,"sourceCode":"\t\tif _, ok := field.Tag.Lookup(name); ok {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\nfunc unwrapProvided(t reflect.Type) (reflect.Type, []int, bool, error) {\n\tpublicProvided := t.PkgPath() == extensionCommandPkgPath && strings.HasPrefix(t.Name(), \"Provided[\")\n\tif t.Kind() != reflect.Struct || !publicProvided {\n\t\treturn t, nil, false, nil\n\t}\n\tvalue, ok := t.FieldByName(\"Value\")\n\tif !ok {\n\t\treturn nil, nil, false, fmt.Errorf(\"Provided type has no Value field\")\n\t}\n\tset, ok := t.FieldByName(\"Set\")\n\tif !ok || set.Type.Kind() != reflect.Bool {\n\t\treturn nil, nil, false, fmt.Errorf(\"Provided type has invalid Set field\")\n\t}\n\treturn value.Type, value.Index, true, nil\n}\n\nfunc mergeInputSupplement(field *compiledInputField, supplement typedInputField) error {\n\tif supplement.Description != \"\" {\n\t\tif field.description != \"\" {\n\t\t\treturn fmt.Errorf(\"description is declared by both doc and InputField.Description\")\n\t\t}\n\t\tfield.description = strings.TrimSpace(supplement.Description)\n\t}\n\tif supplement.Shape != nil {\n\t\tif shapeHasConstraints(field.shape) || field.nullable != nil {\n\t\t\treturn fmt.Errorf(\"Shape conflicts with schema constraints or nullable declaration\")\n\t\t}\n\t\tshape, err := lowerAuthoringShape(supplement.Shape)\n\t\tif err != nil {\n\t\t\treturn err","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L180-L216","documentation":"Companion to the Value-field check: a type matched the Provided[T] pattern (package path + name prefix) but its `Set` field is missing or is not a plain bool. The Set bool is how the runtime records whether the user supplied the flag, so it is mandatory.","triggerScenarios":"Declaring `type Provided[T any] struct { Value T }` (no Set) or `type Provided[T any] struct { Value T; Set string }` in the extension/command package path and using it as an Args field type.","commonSituations":"Trimming a vendored Provided type; changing Set to a custom type during refactoring; generated code emitting the wrong Set type.","solutions":["Ensure the struct has `Set bool` alongside `Value T`.","Switch to the canonical Provided[T] from extension/command.","If the type is not intended as a Provided wrapper, rename it away from the `Provided[` prefix."],"exampleFix":"// before\ntype Provided[T any] struct { Value T; Set *bool }\n// after\ntype Provided[T any] struct { Value T; Set bool }","handlingStrategy":"type-guard","validationCode":"t := reflect.TypeOf(field)\nif strings.HasPrefix(t.Name(), \"Provided[\") {\n\tset, ok := t.FieldByName(\"Set\")\n\tif !ok || set.Type.Kind() != reflect.Bool {\n\t\treturn errors.New(\"Provided type requires an exported Set bool field\")\n\t}\n}","typeGuard":"func hasBoolSetField(t reflect.Type) bool {\n\tif !strings.HasPrefix(t.Name(), \"Provided[\") { return true }\n\tf, ok := t.FieldByName(\"Set\")\n\treturn ok && f.Type.Kind() == reflect.Bool\n}","tryCatchPattern":null,"preventionTips":["Never remove or retype the Set bool when customizing Provided structs.","Prefer the stock Provided[T]; treat its field layout as a contract.","Run startup compilation of shortcuts in CI to catch layout drift."],"tags":["go","generics","reflection","cli"],"backgroundTag":"invalid-provided-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"}