{"record":{"id":"f3993c14da96286a","repo":"larksuite/cli","slug":"args-field-s-s-inputfield-shape-conflicts-w","errorCode":null,"errorMessage":"Args field %s (--%s): InputField.Shape conflicts with schema constraints or nullable declaration","messagePattern":"Args field (.+?) \\(--(.+?)\\): InputField\\.Shape conflicts with schema constraints or nullable declaration","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":152,"sourceCode":"\t\t\treturn fmt.Errorf(\"Args field %s (--%s): json tag is not allowed on a CLI field\", field.Name, flagName)\n\t\t}\n\t\tvalueType, valueIndex, isProvided, err := unwrapProvided(field.Type)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Args field %s (--%s): %w\", field.Name, flagName, err)\n\t\t}\n\t\tschema, err := parseSchemaTag(field.Tag.Get(\"schema\"), valueType, true)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Args field %s (--%s): %w\", field.Name, flagName, err)\n\t\t}\n\t\tcli, err := parseCLITag(field.Tag.Get(\"cli\"))\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"Args field %s (--%s): %w\", field.Name, flagName, err)\n\t\t}\n\t\tvar shape typedValueShape\n\t\tsupplement, hasSupplement := supplements[flagName]\n\t\tif hasSupplement && supplement.Shape != nil {\n\t\t\tif schema.nullable != nil || schemaHasShapeConstraints(schema) {\n\t\t\t\treturn fmt.Errorf(\"Args field %s (--%s): InputField.Shape conflicts with schema constraints or nullable declaration\", field.Name, flagName)\n\t\t\t}\n\t\t} else {\n\t\t\tshape, err = shapeForType(valueType, schema, true, map[reflect.Type]struct{}{})\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"Args field %s (--%s): %w\", field.Name, flagName, err)\n\t\t\t}\n\t\t}\n\t\t*out = append(*out, compiledInputField{\n\t\t\tname:         flagName,\n\t\t\tgoName:       field.Name,\n\t\t\tindex:        index,\n\t\t\tvalueIndex:   valueIndex,\n\t\t\tvalueType:    valueType,\n\t\t\tprovided:     isProvided,\n\t\t\trequired:     schema.required,\n\t\t\tnullable:     schema.nullable,\n\t\t\tdescription:  strings.TrimSpace(field.Tag.Get(\"doc\")),\n\t\t\tshape:        shape,","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L134-L170","documentation":"When an InputField (declared in code via Input.Fields) supplies a Shape for a flag, the Args struct field itself must not also declare shape-affecting schema constraints (enum, format, minLength/maxLength, minimum/maximum, minItems/maxItems) or a nullable/nonnullable declaration. Both sources of truth would conflict, so compilation fails.","triggerScenarios":"An Args field like `Status string \\`flag:\"status\" schema:\"required;enum=open|closed\"\\`` while the shortcut registration also passes InputField{Name:\"status\", Shape: StringShape{Enum:...}}.","commonSituations":"Migrating constraints from struct tags to programmatic InputField declarations without deleting the old schema tokens; team members adding the same constraint in both places during refactors.","solutions":["Pick one source of truth: either keep the schema constraints in the tag and drop InputField.Shape, or keep InputField.Shape and strip enum/format/min*/max*/nullable tokens from the schema tag.","Keep only `required`/`optional` in the schema tag when InputField.Shape is provided."],"exampleFix":"// before\nStatus string `flag:\"status\" schema:\"required;enum=open|closed\"`\n// with InputField{Shape: ...}\n// after\nStatus string `flag:\"status\" schema:\"required\" doc:\"Ticket status\"`\n// keep constraints in InputField.Shape","handlingStrategy":"validation","validationCode":"if inputField.Shape != nil {\n\tfor _, c := range []string{\"enum\", \"format\", \"minLength\", \"maxLength\", \"minimum\", \"maximum\", \"minItems\", \"maxItems\", \"nullable\", \"nonnullable\"} {\n\t\tif strings.Contains(field.Tag.Get(\"schema\"), c) {\n\t\t\treturn fmt.Errorf(\"flag %s: drop schema constraint %q when InputField.Shape is set\", name, c)\n\t\t}\n\t}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Choose one declaration site per constraint: tags or InputField.Shape, never both.","When migrating constraints into InputField.Shape, delete the schema tokens in the same commit.","Register all shortcuts in an init-time test to catch conflicts before deploy."],"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"}