{"record":{"id":"8062c6c9c6f34088","repo":"larksuite/cli","slug":"s-must-be-null","errorCode":null,"errorMessage":"%s must be null","messagePattern":"(.+?) must be null","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":397,"sourceCode":"\t\treturn typedFieldValidation(field, \"%v\", err).WithCause(err)\n\t}\n\treturn nil\n}\n\nfunc validateJSONValueAgainstShape(value any, shape typedValueShape, path string) error {\n\tswitch constraint := shape.(type) {\n\tcase anyJSONShape:\n\t\treturn nil\n\tcase typedOneOfShape:\n\t\tfor _, variant := range constraint.Variants {\n\t\t\tif err := validateJSONValueAgainstShape(value, variant, path); err == nil {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}\n\t\treturn fmt.Errorf(\"%s does not match any allowed shape\", path)\n\tcase typedNullShape:\n\t\tif value != nil {\n\t\t\treturn fmt.Errorf(\"%s must be null\", path)\n\t\t}\n\t\treturn nil\n\tcase typedConstShape:\n\t\texpectedJSON, err := json.Marshal(constraint.Value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s has invalid const: %w\", path, err)\n\t\t}\n\t\texpected, err := decodeJSONValidationValue(expectedJSON)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"%s has invalid const: %w\", path, err)\n\t\t}\n\t\tif !reflect.DeepEqual(value, expected) {\n\t\t\treturn fmt.Errorf(\"%s must equal %v\", path, constraint.Value)\n\t\t}\n\t\treturn nil\n\tcase typedStringShape:\n\t\ttext, ok := value.(string)\n\t\tif !ok {","sourceCodeStart":379,"sourceCodeEnd":415,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L379-L415","documentation":"Typed-binder shape validation: a value bound to a nullable-only slot (typedNullShape) is not JSON null. Fires when user input supplies a non-null value where the schema only permits null.","triggerScenarios":"Passing any non-nil value (string, number, object, even empty string or 0) to a field whose compiled shape is typedNullShape.","commonSituations":"APIs that use explicit null fields to clear a value; developers mistakenly send a placeholder like \"\" or \"none\" instead of nil, or a code path fails to omit the field and inserts a default value.","solutions":["Set the field's value to nil (or omit it entirely) instead of a placeholder value.","Remove the field from the request if you did not intend to clear it.","If the field should accept real values, fix its shape constraint — it is likely declared null by mistake."],"exampleFix":"// before\nparams.Set(\"description\", \"\") // null-typed field\n\n// after\nparams.Set(\"description\", nil) // or don't set the field","handlingStrategy":"validation","validationCode":"if v != nil { return fmt.Errorf(\"field must be nil or omitted\") }","typeGuard":"func isNil(v any) bool {\n    if v == nil { return true }\n    rv := reflect.ValueOf(v)\n    switch rv.Kind() {\n    case reflect.Ptr, reflect.Map, reflect.Slice, reflect.Chan, reflect.Func, reflect.Interface:\n        return rv.IsNil()\n    }\n    return false\n}","tryCatchPattern":"if err := binder.Set(\"description\", val); err != nil {\n    if strings.Contains(err.Error(), \"must be null\") {\n        return fmt.Errorf(\"description only accepts null (to clear); got %v\", val)\n    }\n    return err\n}","preventionTips":["Use nil, not \"\" or 0, for clear-value semantics.","Omit optional fields entirely when you have no value.","Check the field's shape before writing clear/update logic."],"tags":["go","schema-validation","null","shape-constraint"],"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"}