{"record":{"id":"9573a6d8804a8cb1","repo":"larksuite/cli","slug":"default-is-declared-by-both-schema-and-inputfield","errorCode":null,"errorMessage":"default is declared by both schema and InputField.Default","messagePattern":"default is declared by both schema and InputField\\.Default","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":229,"sourceCode":"\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\n\t\t}\n\t\tif err := validateShape(shape, \"InputField.Shape\"); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !shapeCompatibleWithType(shape, field.valueType) {\n\t\t\treturn fmt.Errorf(\"InputField.Shape %T is incompatible with Go type %s\", supplement.Shape, field.valueType)\n\t\t}\n\t\tfield.shape = shape\n\t\tfield.shapeExplicit = true\n\t}\n\tif supplement.Default.Set {\n\t\tif field.defaultValue.Set {\n\t\t\treturn fmt.Errorf(\"default is declared by both schema and InputField.Default\")\n\t\t}\n\t\tif field.required {\n\t\t\treturn fmt.Errorf(\"required input cannot declare a default\")\n\t\t}\n\t\tfield.defaultValue = supplement.Default\n\t}\n\tif len(supplement.CLI.Aliases) > 0 {\n\t\tif len(field.cli.Aliases) > 0 {\n\t\t\treturn fmt.Errorf(\"CLI.Aliases is declared by both cli tag and InputField.CLI\")\n\t\t}\n\t\tfield.cli.Aliases = append([]typedFlagAlias(nil), supplement.CLI.Aliases...)\n\t}\n\tif len(supplement.CLI.ValueSources) > 0 {\n\t\tif len(field.cli.ValueSources) > 0 {\n\t\t\treturn fmt.Errorf(\"CLI.ValueSources is declared by both cli tag and InputField.CLI\")\n\t\t}\n\t\tfield.cli.ValueSources = append([]typedValueSource(nil), supplement.CLI.ValueSources...)\n\t}","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L211-L247","documentation":"A default value was supplied in two places for one flag: the schema tag on the Args struct field (schema:\"...,default=...\") and InputField.Default. The library forbids ambiguity so the effective default is never uncertain.","triggerScenarios":"compileInput -> mergeInputSupplement when supplement.Default.Set is true and the field's schema-parsed defaultValue is already Set.","commonSituations":"Adding an InputField.Default supplement to a field that already carries a default= entry in its schema tag, or vice versa after duplicating declarations during a refactor.","solutions":["Keep the default in exactly one place: remove it from the schema tag or delete the InputField.Default supplement.","If programmatic control is needed, strip default= from the schema tag and keep only InputField.Default."],"exampleFix":"// before\nLimit int `flag:\"limit\" schema:\"default=10\"` + InputField{Name: \"limit\", Default: ...}\n// after\nLimit int `flag:\"limit\"` + InputField{Name: \"limit\", Default: ...}","handlingStrategy":"validation","validationCode":"for _, f := range fields {\n    if f.SchemaDefault != nil && f.InputDefault.Set {\n        return fmt.Errorf(\"flag %s: default declared twice\", f.Name)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick one declaration channel per flag (tags OR InputField) per property and stick to it.","Grep the codebase for existing default= tags before adding InputField.Default.","Compile command sets in CI tests to catch conflicts immediately."],"tags":["cli","typed-input","duplicate-declaration","default-value"],"backgroundTag":"conflicting-declaration","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"}