{"record":{"id":"e560c7b9db0eee38","repo":"larksuite/cli","slug":"array-item-w","errorCode":null,"errorMessage":"array item: %w","messagePattern":"array item: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_data.go","lineNumber":149,"sourceCode":"\t\t}\n\t\tif hasStringConstraints(schema) || hasItemConstraints(schema) || schema.format != \"\" {\n\t\t\treturn nil, fmt.Errorf(\"number field has incompatible schema constraint\")\n\t\t}\n\t\tshape = numberShape\n\tcase reflect.Slice, reflect.Array:\n\t\tif baseType == jsonRawMessageType {\n\t\t\treturn nil, fmt.Errorf(\"json.RawMessage requires an explicit Shape\")\n\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)","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_data.go#L131-L167","documentation":"This is a wrapping error: while deriving the schema of an array field, shapeForType recursed into the element type and that recursion failed (e.g. the element is json.RawMessage, []byte, a map, an interface, or has its own incompatible constraints). The compiler prefixes the element error with \"array item:\" to point at the offending position in the type tree.","triggerScenarios":"Declaring fields like []map[string]string, []json.RawMessage, or [][]byte; also []someStruct where someStruct itself fails compilation — the inner cause is chained via %w.","commonSituations":"Loosely typed collections from generic API clients; nested DTOs that were valid under encoding/json but have no static shape; recently refactored element types.","solutions":["Read the wrapped cause below this message to find which element type failed and why.","Replace the offending element type with a concrete mappable type (string, int, bool, float, plain struct).","Give an explicit Output.Data.Shape describing the array's item shape.","If items are truly arbitrary, restructure Data as `any` or provide a Shape with permissive items."],"exampleFix":"// before\nRows []map[string]any `json:\"rows\"`\n\n// after\ntype Row struct {\n    Name string `json:\"name\"`\n    Val  int    `json:\"val\"`\n}\nRows []Row `json:\"rows\"`","handlingStrategy":"try-catch","validationCode":"// Pre-walk element types before registration:\nfunc checkArrayElems(t reflect.Type) error {\n    for t.Kind() == reflect.Pointer { t = t.Elem() }\n    if t.Kind() == reflect.Slice || t.Kind() == reflect.Array {\n        if err := checkArrayElems(t.Elem()); err != nil {\n            return fmt.Errorf(\"array item: %w\", err)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if _, err := compileShortcut(cmd); err != nil {\n    var chain []string\n    for e := err; e != nil; e = errors.Unwrap(e) {\n        chain = append(chain, e.Error())\n    }\n    // innermost entry names the failing element type\n    slog.Error(\"data shape compile failed\", \"chain\", chain)\n    return err\n}","preventionTips":["Read the wrapped cause chain (errors.Unwrap) to locate the failing element type.","Prefer concrete element structs over []map/[]interface{} collections.","Smoke-test command registration in unit tests to catch element failures early."],"tags":["go","array","error-wrapping","schema"],"backgroundTag":"explicit-shape-required","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"}