larksuite/cli · error
Args field %s (--%s): InputField.Shape conflicts with schema
Error message
Args field %s (--%s): InputField.Shape conflicts with schema constraints or nullable declaration
What it means
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.
Source
Thrown at shortcuts/common/typed_compile_args.go:152
return fmt.Errorf("Args field %s (--%s): json tag is not allowed on a CLI field", field.Name, flagName)
}
valueType, valueIndex, isProvided, err := unwrapProvided(field.Type)
if err != nil {
return fmt.Errorf("Args field %s (--%s): %w", field.Name, flagName, err)
}
schema, err := parseSchemaTag(field.Tag.Get("schema"), valueType, true)
if err != nil {
return fmt.Errorf("Args field %s (--%s): %w", field.Name, flagName, err)
}
cli, err := parseCLITag(field.Tag.Get("cli"))
if err != nil {
return fmt.Errorf("Args field %s (--%s): %w", field.Name, flagName, err)
}
var shape typedValueShape
supplement, hasSupplement := supplements[flagName]
if hasSupplement && supplement.Shape != nil {
if schema.nullable != nil || schemaHasShapeConstraints(schema) {
return fmt.Errorf("Args field %s (--%s): InputField.Shape conflicts with schema constraints or nullable declaration", field.Name, flagName)
}
} else {
shape, err = shapeForType(valueType, schema, true, map[reflect.Type]struct{}{})
if err != nil {
return fmt.Errorf("Args field %s (--%s): %w", field.Name, flagName, err)
}
}
*out = append(*out, compiledInputField{
name: flagName,
goName: field.Name,
index: index,
valueIndex: valueIndex,
valueType: valueType,
provided: isProvided,
required: schema.required,
nullable: schema.nullable,
description: strings.TrimSpace(field.Tag.Get("doc")),
shape: shape,View on GitHub (pinned to 7fd6ef3c07)
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.
Example fix
// before
Status string `flag:"status" schema:"required;enum=open|closed"`
// with InputField{Shape: ...}
// after
Status string `flag:"status" schema:"required" doc:"Ticket status"`
// keep constraints in InputField.Shape Defensive patterns
Strategy: validation
Validate before calling
if inputField.Shape != nil {
for _, c := range []string{"enum", "format", "minLength", "maxLength", "minimum", "maximum", "minItems", "maxItems", "nullable", "nonnullable"} {
if strings.Contains(field.Tag.Get("schema"), c) {
return fmt.Errorf("flag %s: drop schema constraint %q when InputField.Shape is set", name, c)
}
}
} Prevention
- 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.
When it happens
Trigger: 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:...}}.
Common situations: 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.
Related errors
- Shape conflicts with schema constraints or nullable declarat
- %s must contain at most %d characters
- %s must be one of: %s
- description is declared by both doc and InputField.Descripti
- schema tag must declare exactly one of required or optional
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/f3993c14da96286a.
Report an issue: GitHub.