{"record":{"id":"345ec0112322bd65","repo":"larksuite/cli","slug":"provided-type-has-no-value-field","errorCode":null,"errorMessage":"Provided type has no Value field","messagePattern":"Provided type has no Value field","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":194,"sourceCode":"}\n\nfunc hasAnyTag(field reflect.StructField, names ...string) bool {\n\tfor _, name := range names {\n\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\")","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L176-L212","documentation":"unwrapProvided recognizes a Provided[T]-style type by its package path and `Provided[` name prefix, then requires exported `Value` and `Set` fields. This error means a type matched the Provided naming/package pattern but has no `Value` field, so the compiler cannot extract the underlying flag value.","triggerScenarios":"Declaring a custom generic named `Provided[T]` inside a package that resolves to the extension/command package path without a `Value` field, e.g. `type Provided[T any] struct { Data T; Present bool }`.","commonSituations":"Vendoring or copying Provided[T] and renaming fields; local reimplementation for tests; code generation that dropped the Value field.","solutions":["Add an exported `Value` field of the value type to the Provided struct.","Better: use the canonical Provided[T] from github.com/larksuite/cli/extension/command rather than a local copy.","If this is not meant to be a Provided type, rename it so it no longer starts with `Provided[`."],"exampleFix":"// before\ntype Provided[T any] struct { Data T; Present 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\tif _, ok := t.FieldByName(\"Value\"); !ok {\n\t\treturn errors.New(\"Provided type is missing the Value field\")\n\t}\n}","typeGuard":"func hasValueField(t reflect.Type) bool {\n\tif !strings.HasPrefix(t.Name(), \"Provided[\") { return true }\n\tf, ok := t.FieldByName(\"Value\")\n\treturn ok && f.IsExported()\n}","tryCatchPattern":null,"preventionTips":["Use the canonical Provided[T] from extension/command instead of custom copies.","Keep Provided wrappers as `struct{ Value T; Set bool }` exactly.","Add a reflection test over all Args field types checking Provided shape."],"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"}