{"record":{"id":"a740a9bb6f922cc6","repo":"larksuite/cli","slug":"object-field-has-incompatible-schema-constraint","errorCode":null,"errorMessage":"object field has incompatible schema constraint","messagePattern":"object field has incompatible schema constraint","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_data.go","lineNumber":157,"sourceCode":"\t\t}\n\t\tif baseType.Elem().Kind() == reflect.Uint8 {\n\t\t\treturn nil, fmt.Errorf(\"byte slice or array %s requires an explicit Shape\", baseType)\n\t\t}\n\t\tif len(schema.enum) > 0 || hasStringConstraints(schema) || hasNumberConstraints(schema) || schema.format != \"\" {\n\t\t\treturn nil, fmt.Errorf(\"array field has incompatible schema constraint\")\n\t\t}\n\t\telementSchema := schemaTag{required: true}\n\t\telementShape, err := shapeForType(baseType.Elem(), elementSchema, input, active)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"array item: %w\", err)\n\t\t}\n\t\tshape = typedArrayShape{Items: elementShape, MinItems: schema.minItems, MaxItems: schema.maxItems}\n\tcase reflect.Struct:\n\t\tif implementsCustomEncoding(baseType) {\n\t\t\treturn nil, fmt.Errorf(\"custom JSON type %s requires an explicit Shape\", baseType)\n\t\t}\n\t\tif len(schema.enum) > 0 || hasStringConstraints(schema) || hasNumberConstraints(schema) || hasItemConstraints(schema) || schema.format != \"\" {\n\t\t\treturn nil, fmt.Errorf(\"object field has incompatible schema constraint\")\n\t\t}\n\t\tobject, err := compileStructShape(baseType, input, baseType.String(), active)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tshape = object\n\tcase reflect.Map:\n\t\treturn nil, fmt.Errorf(\"map type %s requires an explicit Shape\", baseType)\n\tcase reflect.Interface:\n\t\treturn nil, fmt.Errorf(\"interface type %s requires an explicit Shape\", baseType)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"Go type %s cannot be mapped to a ValueShape\", t)\n\t}\n\tif schema.nullable != nil && *schema.nullable {\n\t\tshape = typedOneOfShape{Variants: []typedValueShape{shape, typedNullShape{}}}\n\t}\n\treturn shape, nil\n}","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_data.go#L139-L175","documentation":"A struct-typed field was tagged with schema constraints that only apply to scalars: enum values, string constraints, number constraints, item constraints, or format. Object shapes support field-level constraints via their own fields, so these tags describe an impossible combination and compilation is aborted.","triggerScenarios":"A field like `someStruct `+\"`\"+`schema:\"format=uri\"`+\"`\"+` or `+\"`\"+`schema:\"enum=a\"`+\"`\"+` where the Go type is a struct reaches the reflect.Struct case in shapeForType.","commonSituations":"Schema tags copied from a neighboring string field; a generator adding format to every field; a field's Go type changed from string to struct without updating the tag.","solutions":["Remove the scalar-only constraint tags from the struct field.","Apply the constraint to the relevant inner field of the struct instead.","If a scalar is really intended, change the field type back (e.g. string) so the tag is valid.","Alternatively supply an explicit Output.Data.Shape with the constraints placed where they apply."],"exampleFix":"// before\ntype Owner struct {\n    ID string `json:\"id\"`\n}\nOwner Owner `json:\"owner\" schema:\"format=uri\"`\n\n// after\nOwner Owner `json:\"owner\"` // no scalar tags; constrain Owner.ID instead","handlingStrategy":"validation","validationCode":"func structTagsValid(f reflect.StructField) bool {\n    if f.Type.Kind() != reflect.Struct { return true }\n    tag := f.Tag.Get(\"schema\")\n    for _, bad := range []string{\"enum=\", \"format=\", \"minLength=\", \"maxLength=\", \"minimum=\", \"maximum=\", \"minItems=\", \"maxItems=\"} {\n        if strings.Contains(tag, bad) { return false }\n    }\n    return true\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Struct fields carry no scalar schema tags; constrain inner fields instead.","Lint schema tags when refactoring a field from string to struct (or back).","Code-review generated tags: generators often emit format= on every field."],"tags":["go","schema-tag","object","validation"],"backgroundTag":"incompatible-schema-constraint","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"}