{"record":{"id":"80aebe4b71f75dae","repo":"larksuite/cli","slug":"s-must-be-an-object","errorCode":null,"errorMessage":"%s must be an object","messagePattern":"(.+?) must be an object","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":488,"sourceCode":"\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be an array\", path)\n\t\t}\n\t\tif constraint.MinItems != nil && len(items) < *constraint.MinItems {\n\t\t\treturn fmt.Errorf(\"%s must contain at least %d items\", path, *constraint.MinItems)\n\t\t}\n\t\tif constraint.MaxItems != nil && len(items) > *constraint.MaxItems {\n\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 {","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L470-L506","documentation":"Object shape validation: a field declared as a typed object received a value that is not a JSON object after decoding. The type assertion to map[string]any fails and the binder reports the field path.","triggerScenarios":"Passing a scalar or array where a JSON object flag is expected — e.g. --settings 'foo' or --settings '[1,2]' instead of '{\"key\":\"value\"}'.","commonSituations":"Shell quoting mangling braces; forgetting the outer {} around key/value payloads; config files storing a stringified object without parsing; nesting mistakes (object expected, array of objects given).","solutions":["Wrap the value as a JSON object with braces and quoted keys.","Verify with --help/schema that the field is an object and inspect its declared fields.","Quote the whole argument to survive shell brace expansion.","Validate the JSON with a parser (jq) before passing it."],"exampleFix":"// before\nlark-cli shortcut demo --settings 'key=value'\n// error: settings must be an object\n\n// after\nlark-cli shortcut demo --settings '{\"key\":\"value\"}'","handlingStrategy":"type-guard","validationCode":"value='{\"a\":1}'\necho \"$value\" | jq -e 'type==\"object\"' >/dev/null || { echo \"expected a JSON object\" >&2; exit 2; }","typeGuard":"func isJSONObject(raw string) bool {\n    var v map[string]any\n    return json.Unmarshal([]byte(raw), &v) == nil\n}","tryCatchPattern":"err := cmd.Run()\nvar valErr *errs.ValidationError\nif errors.As(err, &valErr) && strings.Contains(valErr.Error(), \"must be an object\") {\n    // fix the payload to a JSON object and retry\n}","preventionTips":["Single-quote JSON payloads to protect braces from the shell.","Validate with jq type==\"object\" before invoking.","Confirm the field is object-shaped via schema.","Build nested payloads by marshaling maps, not string concatenation."],"tags":["validation","cli","json","type-mismatch"],"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"}