Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic reflect #799

Closed
tpoxa opened this issue Mar 8, 2023 · 2 comments
Closed

Panic reflect #799

tpoxa opened this issue Mar 8, 2023 · 2 comments

Comments

@tpoxa
Copy link

tpoxa commented Mar 8, 2023

I use protobuf generated struct as one of my model's field

type Element struct {
	bun.BaseModel `bun:"table:elements,alias:element"`
	ID            string                 `bun:"id,nullzero,notnull,pk"`
	FlowID        int                    `bun:"flow_id,nullzero,notnull,pk"`
	Revision      int                    `bun:"revision,nullzero,notnull,pk"`
	Component     string                 `bun:",nullzero"`
	Data          *platform.GraphElement `bun:",nullzero,notnull,type:jsonb"`
}

GraphElement consists of structured elements, which we use in some grpc responses as is.

During insert, I've caught the following panic message:

[bun]  23:00:02.390   ROLLBACK                  9µs  ROLLBACK     *errors.errorString: driver: bad connection 
panic: reflect: call of reflect.Value.Field on ptr Value

goroutine 269 [running]:
reflect.Value.Field({0x105c49c20?, 0x14000b00df8?, 0x140008ce788?}, 0x80?)
        /opt/homebrew/Cellar/go/1.19.4/libexec/src/reflect/value.go:1266 +0xec
github.com/uptrace/bun/schema.fieldByIndex({0x105c49c20?, 0x14000b00df8?, 0x140007f9cd8?}, {0x140002265f0?, 0x140007f9cd0?, 0x104e1de6c?})
        /Users/tpoxa/go/pkg/mod/github.com/uptrace/bun@v1.1.10/schema/reflect.go:33 +0x44
github.com/uptrace/bun/schema.(*Field).ScanValue(0x140005bab00, {0x105c49c20?, 0x14000b00df8?, 0x9?}, {0x0, 0x0})
        /Users/tpoxa/go/pkg/mod/github.com/uptrace/bun@v1.1.10/schema/field.go:114 +0x50
github.com/uptrace/bun.(*structTableModel).scanColumn(0x14000242a50, {0x14000823180, 0x9}, {0x0, 0x0})
        /Users/tpoxa/go/pkg/mod/github.com/uptrace/bun@v1.1.10/model_table_struct.go:331 +0xe0
github.com/uptrace/bun.(*structTableModel).ScanColumn(0x14000242a50, {0x14000823180, 0x9}, {0x0?, 0x0?})
        /Users/tpoxa/go/pkg/mod/github.com/uptrace/bun@v1.1.10/model_table_struct.go:311 +0x30
github.com/uptrace/bun.(*structTableModel).Scan(0x0?, {0x0?, 0x0?})
        /Users/tpoxa/go/pkg/mod/github.com/uptrace/bun@v1.1.10/model_table_struct.go:307 +0x9c
database/sql.convertAssignRows({0x105df51a0?, 0x14000242a50}, {0x0?, 0x0}, 0x14000af2980)
        /opt/homebrew/Cellar/go/1.19.4/libexec/src/database/sql/convert.go:385 +0x1f80

go version go1.19.4 darwin/arm64

Is this because of protoc-generated structs?
Thanks.

@vmihailenco
Copy link
Member

This is probabably fixed in v1.1.12

@tpoxa
Copy link
Author

tpoxa commented Mar 9, 2023

Indeed it is, thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants