{"record":{"id":"4b0c068f2df11e33","repo":"go-gorm/gorm","slug":"invalid-embedded-struct-for-s-s-field-s-should","errorCode":null,"errorMessage":"invalid embedded struct for %s's field %s, should be struct, but got %v","messagePattern":"invalid embedded struct for (.+?)'s field (.+?), should be struct, but got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"schema/field.go","lineNumber":443,"sourceCode":"\t\t\t\t\t\tef.PrimaryKey = false\n\n\t\t\t\t\t\tif val, ok := ef.TagSettings[\"AUTOINCREMENT\"]; !ok || !utils.CheckTruth(val) {\n\t\t\t\t\t\t\tef.AutoIncrement = false\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif !ef.AutoIncrement && ef.DefaultValue == \"\" {\n\t\t\t\t\t\t\tef.HasDefaultValue = false\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor k, v := range field.TagSettings {\n\t\t\t\t\tef.TagSettings[k] = v\n\t\t\t\t}\n\t\t\t}\n\t\tcase reflect.Invalid, reflect.Uintptr, reflect.Array, reflect.Chan, reflect.Func, reflect.Interface,\n\t\t\treflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer, reflect.Complex64, reflect.Complex128:\n\t\t\tschema.err = fmt.Errorf(\"invalid embedded struct for %s's field %s, should be struct, but got %v\", field.Schema.Name, field.Name, field.FieldType)\n\t\t}\n\t}\n\n\treturn field\n}\n\n// create valuer, setter when parse struct\nfunc (field *Field) setupValuerAndSetter(modelType reflect.Type) {\n\t// Setup NewValuePool\n\tfield.setupNewValuePool()\n\n\t// ValueOf returns field's value and if it is zero\n\tfieldIndex := field.StructField.Index[0]\n\tswitch {\n\tcase len(field.StructField.Index) == 1 && fieldIndex >= 0:\n\t\tfield.ValueOf = func(ctx context.Context, v reflect.Value) (interface{}, bool) {\n\t\t\tv = reflect.Indirect(v)\n\t\t\tfieldValue := v.Field(fieldIndex)","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/go-gorm/gorm/blob/1d6ce99528060be18a42be09aca8d39efcb47f28/schema/field.go#L425-L461","documentation":"Error \"invalid embedded struct for %s's field %s, should be struct, but got %v\" thrown in go-gorm/gorm.","triggerScenarios":"Thrown at schema/field.go:443 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the field marked with `gorm:\"embedded\"` is a struct or pointer to struct.","Remove the embedded tag from non-struct fields.","Check for typo'd field types in the embedded field declaration."],"exampleFix":"Make the embedded field a struct (not pointer to non-struct): `gorm:\"embedded\"` on a struct type field.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1d6ce99528060be18a42be09aca8d39efcb47f28","analyzedAt":"2026-08-15T13:01:23.433Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}