{"record":{"id":"67565eb57dfab66c","repo":"larksuite/cli","slug":"s-s-is-required","errorCode":null,"errorMessage":"%s.%s is required","messagePattern":"(.+?)\\.(.+?) is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":495,"sourceCode":"\t\t\treturn fmt.Errorf(\"%s must contain at most %d items\", path, *constraint.MaxItems)\n\t\t}\n\t\tfor i, item := range items {\n\t\t\tif err := validateJSONValueAgainstShape(item, constraint.Items, fmt.Sprintf(\"%s[%d]\", path, i)); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t\treturn nil\n\tcase typedObjectShape:\n\t\tobject, ok := value.(map[string]any)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be an object\", path)\n\t\t}\n\t\tfields := make(map[string]typedValueField, len(constraint.Fields))\n\t\tfor _, field := range constraint.Fields {\n\t\t\tfields[field.Name] = field\n\t\t\tif field.Required {\n\t\t\t\tif _, exists := object[field.Name]; !exists {\n\t\t\t\t\treturn fmt.Errorf(\"%s.%s is required\", path, field.Name)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor name, item := range object {\n\t\t\tfield, exists := fields[name]\n\t\t\tif !exists {\n\t\t\t\tif !constraint.AdditionalProperties {\n\t\t\t\t\treturn fmt.Errorf(\"%s contains unknown field %q\", path, name)\n\t\t\t\t}\n\t\t\t\tif constraint.AdditionalPropertiesShape != nil {\n\t\t\t\t\tif err := validateJSONValueAgainstShape(item, constraint.AdditionalPropertiesShape, path+\".\"+name); err != nil {\n\t\t\t\t\t\treturn err\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif err := validateJSONValueAgainstShape(item, field.Shape, path+\".\"+name); err != nil {\n\t\t\t\treturn err","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L477-L513","documentation":"Typed object shape validation: a required field (Name) is absent from the supplied JSON object. Path identifies the parent object and missing field name.","triggerScenarios":"Supplying a JSON object for an object-typed flag while omitting a field marked Required in its shape — e.g. --card '{\"title\":\"x\"}' when card_id is required.","commonSituations":"Partial updates sent as full objects without required keys; renaming a field in a script while the shape still expects the old name; copying examples that omit required members; nested objects where an inner object has required fields.","solutions":["Add the missing key with a valid value to the JSON object.","Check schema/--help for the object's field list and which are required.","Compare your payload against the field names in the error path (nested objects produce dotted paths).","If the field is genuinely optional upstream, verify the shape is generated from current metadata."],"exampleFix":"// before\nlark-cli shortcut demo --card '{\"title\":\"Hello\"}'\n// error: card.card_id is required\n\n// after\nlark-cli shortcut demo --card '{\"card_id\":\"vc_123\",\"title\":\"Hello\"}'","handlingStrategy":"validation","validationCode":"required=(card_id)\nfor key in \"${required[@]}\"; do\n  echo \"$payload\" | jq -e --arg k \"$key\" 'has($k)' >/dev/null || {\n    echo \"missing required field: $k\" >&2; exit 2\n  }\ndone","typeGuard":"func hasRequired(obj map[string]any, keys ...string) bool {\n    for _, k := range keys {\n        if _, ok := obj[k]; !ok { return false }\n    }\n    return true\n}","tryCatchPattern":"err := cmd.Run()\nvar valErr *errs.ValidationError\nif errors.As(err, &valErr) && strings.Contains(valErr.Error(), \" is required\") {\n    // parse the dotted path from the message, add the field, retry\n}","preventionTips":["List required fields with schema/--help before constructing payloads.","Keep payload builders in one place so required keys are never dropped.","Diff your payload keys against the error's dotted path for nested objects.","When renaming fields in scripts, grep for the old name in payloads."],"tags":["validation","cli","json","missing-field"],"backgroundTag":"missing-required-argument","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"}