{"record":{"id":"7b3a4a8e73a9991c","repo":"larksuite/cli","slug":"s-contains-unknown-field-q","errorCode":null,"errorMessage":"%s contains unknown field %q","messagePattern":"(.+?) contains unknown field %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":503,"sourceCode":"\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\n\t\t\t}\n\t\t}\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"%s uses unsupported shape %T\", path, shape)\n\t}\n}\n","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L485-L521","documentation":"Object shape validation: the supplied JSON object contains a key that is not declared in the shape and the shape disallows additional properties (AdditionalProperties=false). The binder rejects unknown keys to prevent silently ignored input.","triggerScenarios":"Passing an object with a typo'd or extra key to an object-typed flag whose shape is closed — e.g. --card '{\"tittle\":\"x\"}' or an extra legacy key no longer in the schema.","commonSituations":"Typo in field names; API version drift where a field was renamed or removed upstream; payloads copied from another endpoint with overlapping but different schemas; snake_case vs camelCase mistakes.","solutions":["Remove the unknown key or fix its spelling to match a declared field.","Run schema/--help to list the exact accepted field names.","Check for API-version drift: the field may have been renamed upstream.","If the object should accept arbitrary keys, the shape's AdditionalProperties must allow it — that is a metadata concern, not a caller flag."],"exampleFix":"// before\nlark-cli shortcut demo --card '{\"card_id\":\"vc_1\",\"tittle\":\"Hi\"}'\n// error: card contains unknown field \"tittle\"\n\n// after\nlark-cli shortcut demo --card '{\"card_id\":\"vc_1\",\"title\":\"Hi\"}'","handlingStrategy":"validation","validationCode":"allowed='{\"card_id\":true,\"title\":true}'\necho \"$payload\" | jq -e --argjson ok \"$allowed\" \\\n  'to_entries | map(.key) - ($ok | keys) | length == 0' >/dev/null || {\n  echo \"payload contains unknown fields\" >&2; exit 2\n}","typeGuard":"func onlyKnownFields(obj map[string]any, allowed map[string]bool) []string {\n    var unknown []string\n    for k := range obj {\n        if !allowed[k] { unknown = append(unknown, k) }\n    }\n    return unknown\n}","tryCatchPattern":"err := cmd.Run()\nvar valErr *errs.ValidationError\nif errors.As(err, &valErr) {\n    var unknErr interface{ UnwrapKey() string }\n    if strings.Contains(valErr.Error(), \"unknown field\") {\n        // extract the key from the message, drop or rename it, retry\n    }\n    _ = unknErr\n}","preventionTips":["Copy field names from schema output, never from memory.","Spell-check keys against the declared field list on typos.","After an upstream API change, re-diff payloads against current schema.","Avoid reusing payloads across endpoints with similar but different shapes."],"tags":["validation","cli","json","unknown-field","typo"],"backgroundTag":"unknown-field-rejected","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"}