{"record":{"id":"59dab4b30e31dec9","repo":"larksuite/cli","slug":"shape-conflicts-with-schema-constraints-or-nullabl","errorCode":null,"errorMessage":"Shape conflicts with schema constraints or nullable declaration","messagePattern":"Shape conflicts with schema constraints or nullable declaration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":212,"sourceCode":"\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\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}","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L194-L230","documentation":"Like error 604 but in mergeInputSupplement: when InputField.Shape is supplied programmatically, the compiled field must not already carry shape constraints from its schema tag (enum, format, string/number/item bounds) or a nullable/nonnullable declaration. Both would define conflicting value shapes.","triggerScenarios":"Args field `Count int \\`flag:\"count\" schema:\"optional;minimum=1\"\\`` combined with InputField{Name:\"count\", Shape: IntegerShape{...}}; also triggered when nullable is declared in the tag while Shape is passed.","commonSituations":"Moving validation from tags to InputField.Shape incrementally; two developers independently adding the same constraint in tag and code.","solutions":["Strip the constraint tokens (enum, format, minLength/maxLength, minimum/maximum, minItems/maxItems, nullable/nonnullable) from the schema tag, keeping only required/optional.","Alternatively drop InputField.Shape and keep the constraints in the tag.","Keep default declarations in exactly one place as well to avoid the related duplicate-default error."],"exampleFix":"// before\nCount int `flag:\"count\" schema:\"optional;minimum=1\"`\n// plus InputField{Name:\"count\", Shape: IntegerShape{Minimum: 1}}\n// after\nCount int `flag:\"count\" schema:\"optional\" doc:\"Item count\"`\n// constraints live only in InputField.Shape","handlingStrategy":"validation","validationCode":"if inputField.Shape != nil && (schemaHasConstraints(field.Tag.Get(\"schema\")) || strings.Contains(field.Tag.Get(\"schema\"), \"nullable\")) {\n\treturn fmt.Errorf(\"flag %s: remove schema constraints/nullable before setting InputField.Shape\", flagName)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep value-shape rules in a single source: tags or InputField.Shape.","When introducing InputField.Shape, strip enum/format/min*/max*/nullable tokens from the tag in the same change.","Register shortcuts in init-time tests so shape conflicts surface during build, not at runtime."],"tags":["cli","schema","conflict","validation"],"backgroundTag":"conflicting-schema-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"}