larksuite/cli · error
Shape conflicts with schema constraints
Error message
Shape conflicts with schema constraints
What it means
During typed command compilation, an Output.Data override replaces a field's schema shape via a DataField with both Path and Shape set. The compiler refuses this replacement when the existing shape already carries schema constraints (enum values, string format, min/max length, min/max value, min/max items, or a oneOf shape), because silently dropping them would weaken the declared contract. The override must target an unconstrained field or the constraint owner must be changed instead.
Source
Thrown at shortcuts/common/typed_compile_data.go:360
}
parts := make([]string, len(encodedParts))
for i, encoded := range encodedParts {
decoded, ok := decodeJSONPointerSegment(encoded)
if !ok {
return fmt.Errorf("segment %q has invalid RFC 6901 escaping", encoded)
}
parts[i] = decoded
}
return mutateObjectField(root, parts, func(field *typedValueField) error {
if override.Description != "" {
if field.Description != "" {
return fmt.Errorf("description is declared by both doc and DataField.Description")
}
field.Description = strings.TrimSpace(override.Description)
}
if override.Shape != nil {
if shapeHasConstraints(field.Shape) {
return fmt.Errorf("Shape conflicts with schema constraints")
}
shape, err := lowerAuthoringShape(override.Shape)
if err != nil {
return err
}
if err := validateShape(shape, "DataField.Shape"); err != nil {
return err
}
field.Shape = shape
}
return nil
})
}
func mutateObjectField(object *typedObjectShape, parts []string, mutate func(*typedValueField) error) error {
name := parts[0]
for i := range object.Fields {
field := &object.Fields[i]View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Remove the Shape field from the DataField override and let the existing constrained shape stand.
- Remove the constraint source (enum/format/min/max tags or oneOf authoring shape) on the base field so the override is legal.
- Point the override Path at a different, unconstrained field if the intent was to reshape that one.
- If both the constraint and the new shape are needed, encode the constraints directly into the override shape (a constrained authoring shape) instead of overriding an already-constrained field.
Example fix
// before
Output.Data.Overrides: []common.TypedDataField{
{Path: "/status", Shape: common.NewStringShape()}, // base field has enum tags
}
// after
Output.Data.Overrides: nil // keep the enum-constrained shape from the struct tags Defensive patterns
Strategy: validation
Validate before calling
func overrideConflicts(fieldShape any) bool {
switch s := fieldShape.(type) {
case common.TypedStringShape:
return len(s.Enum) > 0 || s.Format != "" || s.MinLength != nil || s.MaxLength != nil
case common.TypedIntegerShape, common.TypedNumberShape:
return shapeEnumLen(s) > 0 || shapeBoundsSet(s)
case common.TypedArrayShape:
return s.MinItems != nil || s.MaxItems != nil
case common.TypedOneOfShape:
return true
}
return false
}
// skip the Shape override for fields where overrideConflicts(targetField.Shape) is true Prevention
- Keep shape overrides and schema-constraining tags on disjoint fields.
- Review Output.Data.Overrides against struct tags whenever either side changes.
- Prefer encoding constraints into the override shape itself rather than layering override over constrained base.
When it happens
Trigger: Calling the typed compiler bridge (CompileCommandDefinition / compileDefinition) with Output.Data.Overrides containing an entry whose Path points at a field whose current shape has, e.g., an enum, Format, Minimum/Maximum, MinLength/MaxLength, MinItems/MaxItems, or is a oneOf shape, and whose DataField also sets Shape.
Common situations: A schema comment tag (e.g. enum or format on a struct field) was added or generated metadata tightened the field, while an older DataField override still tries to substitute the shape; copying an override snippet onto a field that already declares constraints.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- expected boolean
- expected integer
- L1: inputSchema must not be nil
- L1: inputSchema.properties must not be nil
- L1: outputSchema must not be nil
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/3c30fd611a956691.
Report an issue: GitHub.