{"record":{"id":"869367cdcf825824","repo":"larksuite/cli","slug":"segment-q-traverses-non-object-shape","errorCode":null,"errorMessage":"segment %q traverses non-object shape","messagePattern":"segment %q traverses non-object shape","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_contract.go","lineNumber":165,"sourceCode":"\t\t\t\treturn field.Shape, nil\n\t\t\t}\n\t\t}\n\t\treturn nil, fmt.Errorf(\"field %q does not exist\", name)\n\tcase typedOneOfShape:\n\t\tvar resolved []typedValueShape\n\t\tfor _, variant := range value.Variants {\n\t\t\tif _, null := variant.(typedNullShape); null {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tfield, err := resolveShapeField(variant, name)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tresolved = append(resolved, field)\n\t\t}\n\t\treturn combineResolvedShapes(resolved)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"segment %q traverses non-object shape\", name)\n\t}\n}\n\nfunc combineResolvedShapes(shapes []typedValueShape) (typedValueShape, error) {\n\tswitch len(shapes) {\n\tcase 0:\n\t\treturn nil, fmt.Errorf(\"shape has no applicable variant\")\n\tcase 1:\n\t\treturn shapes[0], nil\n\tdefault:\n\t\treturn typedOneOfShape{Variants: shapes}, nil\n\t}\n}\n\nfunc shapeAsObject(shape typedValueShape) (typedObjectShape, bool) {\n\tif object, ok := shape.(typedObjectShape); ok {\n\t\treturn object, true\n\t}","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_contract.go#L147-L183","documentation":"During override/pointer traversal, resolveShapeField was asked to descend into a field whose shape is not an object (and not a oneOf that resolves to objects), so a further path segment cannot be applied. The library refuses to traverse into scalars, arrays, or primitives via JSON Pointer segments.","triggerScenarios":"compileData with an override Path having more segments than the nested depth of objects, e.g. Path \"/items/0/name\" where 'items' compiles to an array shape, or \"/count/x\" where 'count' is an int.","commonSituations":"Assuming JSON Pointer array-index syntax works on typed shapes (it does not here); overriding a field inside a scalar; over-nesting a path after refactoring the struct to a flatter shape.","solutions":["Shorten the Path to stop at the last object-typed field and override that field's whole value instead.","If the target is inside an array element, override the array itself or restructure the data so the target is an object field.","Verify the intermediate field's shape is a struct (typedObjectShape) at that depth."],"exampleFix":"// before\n{Path: \"/tags/0\", Value: \"x\"} // tags is []string\n// after\n{Path: \"/tags\", Value: []string{\"x\"}}","handlingStrategy":"type-guard","validationCode":"// ensure the segment being traversed is a struct-typed field\ntype dataShape interface{ FieldNames() []string }\nfunc isObjectField(f any) bool { _, ok := f.(dataShape); return ok }","typeGuard":"func isObjectField(f any) bool {\n  _, ok := f.(interface{ FieldNames() []string })\n  return ok\n}","tryCatchPattern":null,"preventionTips":["Only traverse into struct-typed fields; override scalars and slices at their own path","Keep paths no deeper than the struct's object nesting","Re-verify paths after flattening nested structs"],"tags":["json-pointer","shape-traversal","type-mismatch","shortcuts"],"backgroundTag":"non-object-field-traversal","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"}