protoc-gen-gorm icon indicating copy to clipboard operation
protoc-gen-gorm copied to clipboard

panic: runtime error: invalid memory address or nil pointer dereference

Open an15221315127 opened this issue 2 years ago • 9 comments

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x1315fce]

goroutine 1 [running]: github.com/infobloxopen/protoc-gen-gorm/plugin.(*ORMBuilder).followsUpdateConventions(0xc0000671a0, 0xc000828ea0, 0xc000828ea0, {0x13bb7c7, 0x6}) /Users/anguodong/go/pkg/mod/github.com/infobloxopen/[email protected]/plugin/plugin.go:2814 +0x20e github.com/infobloxopen/protoc-gen-gorm/plugin.(*ORMBuilder).parseServices(0xc0000671a0, 0xc0001be100) /Users/anguodong/go/pkg/mod/github.com/infobloxopen/[email protected]/plugin/plugin.go:2641 +0x54e github.com/infobloxopen/protoc-gen-gorm/plugin.(*ORMBuilder).Generate(0xc0000671a0) /Users/anguodong/go/pkg/mod/github.com/infobloxopen/[email protected]/plugin/plugin.go:282 +0x251 main.main() /Users/anguodong/go/pkg/mod/github.com/infobloxopen/[email protected]/main.go:33 +0xb0 --gorm_out: protoc-gen-gorm: Plugin failed with status code 2. make: *** [api] Error 1

an15221315127 avatar Apr 22 '22 08:04 an15221315127

get this issue too for whenever I have an Update prefix and a string id = 1 and other types on the Request

nonaxanon avatar May 18 '22 16:05 nonaxanon

Same here

AFMiziara avatar Jun 08 '22 22:06 AFMiziara

I solved this issue by modifying plugin.go, in line 2811 added several nil checks Also I upgraded to a new buf builder, 1.4.0 if field == nil || field.Desc == nil || field.Desc.Message() == nil { return false, "", "" } if field.Desc.Message().FullName() == "" { return false, "", "" }

nonaxanon avatar Jun 09 '22 11:06 nonaxanon

Thanks for sharing @nonaxanon ! Any chances these changes can be introduced in here?

AFMiziara avatar Jun 09 '22 14:06 AFMiziara

I solved this issue by modifying plugin.go, in line 2811 added several nil checks Also I upgraded to a new buf builder, 1.4.0 if field == nil || field.Desc == nil || field.Desc.Message() == nil { return false, "", "" } if field.Desc.Message().FullName() == "" { return false, "", "" }

This is not a good resolution.

Doc: Request messages for Create and Update methods should have an Ormable Type in a field named payload

If not the basic Update, should not name UpdateXXX

saltbo avatar Jul 21 '22 08:07 saltbo

why it requires you to add payload field to update when autogen is not specified?

gsingh-ds avatar Apr 17 '23 04:04 gsingh-ds

Is this is for Update prefixed APIs? I have create a project (https://github.com/C0rWin/buf-gorm-demo/blob/main/protos/entity.proto) to demonstrate the behavour which leads to the panic and to be honest I am not clear what is the root cause leading to the panic.

PS. Noted that most comments are almost one year old while still facing this issue, hence wondering whenever it was addressed? Or this is an expected and I'm just doing something wrong?

C0rWin avatar Feb 24 '24 21:02 C0rWin

still facing this issue...

floating-yuan avatar Apr 02 '24 02:04 floating-yuan

I solved this by change every messages named "Update". for me, I change to "Edit", and everything ok

sansan36 avatar Apr 13 '24 11:04 sansan36