{"record":{"id":"3c30fd611a956691","repo":"larksuite/cli","slug":"shape-conflicts-with-schema-constraints","errorCode":null,"errorMessage":"Shape conflicts with schema constraints","messagePattern":"Shape conflicts with schema constraints","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_data.go","lineNumber":360,"sourceCode":"\t}\n\tparts := make([]string, len(encodedParts))\n\tfor i, encoded := range encodedParts {\n\t\tdecoded, ok := decodeJSONPointerSegment(encoded)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"segment %q has invalid RFC 6901 escaping\", encoded)\n\t\t}\n\t\tparts[i] = decoded\n\t}\n\treturn mutateObjectField(root, parts, func(field *typedValueField) error {\n\t\tif override.Description != \"\" {\n\t\t\tif field.Description != \"\" {\n\t\t\t\treturn fmt.Errorf(\"description is declared by both doc and DataField.Description\")\n\t\t\t}\n\t\t\tfield.Description = strings.TrimSpace(override.Description)\n\t\t}\n\t\tif override.Shape != nil {\n\t\t\tif shapeHasConstraints(field.Shape) {\n\t\t\t\treturn fmt.Errorf(\"Shape conflicts with schema constraints\")\n\t\t\t}\n\t\t\tshape, err := lowerAuthoringShape(override.Shape)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif err := validateShape(shape, \"DataField.Shape\"); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tfield.Shape = shape\n\t\t}\n\t\treturn nil\n\t})\n}\n\nfunc mutateObjectField(object *typedObjectShape, parts []string, mutate func(*typedValueField) error) error {\n\tname := parts[0]\n\tfor i := range object.Fields {\n\t\tfield := &object.Fields[i]","sourceCodeStart":342,"sourceCodeEnd":378,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_data.go#L342-L378","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nOutput.Data.Overrides: []common.TypedDataField{\n  {Path: \"/status\", Shape: common.NewStringShape()}, // base field has enum tags\n}\n// after\nOutput.Data.Overrides: nil // keep the enum-constrained shape from the struct tags","handlingStrategy":"validation","validationCode":"func overrideConflicts(fieldShape any) bool {\n  switch s := fieldShape.(type) {\n  case common.TypedStringShape:\n    return len(s.Enum) > 0 || s.Format != \"\" || s.MinLength != nil || s.MaxLength != nil\n  case common.TypedIntegerShape, common.TypedNumberShape:\n    return shapeEnumLen(s) > 0 || shapeBoundsSet(s)\n  case common.TypedArrayShape:\n    return s.MinItems != nil || s.MaxItems != nil\n  case common.TypedOneOfShape:\n    return true\n  }\n  return false\n}\n// skip the Shape override for fields where overrideConflicts(targetField.Shape) is true","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["schema","compile-time","validation"],"backgroundTag":"schema-validation-failed","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"}