Skip to content

gogoproto: calling .String() can panic #63299

@tbg

Description

@tbg

Describe the problem

For some reason, (*raftpb.Entry).String() panics, see #63298:

"field raftpb.Entry.Term has invalid type: got uint64, want pointer"

This smells a lot like it has something to do with (gogoproto.nullable)=true:

message Entry {
	optional uint64     Term  = 2 [(gogoproto.nullable) = false]; // must be 64-bit aligned for atomic operations
	optional uint64     Index = 3 [(gogoproto.nullable) = false]; // must be 64-bit aligned for atomic operations
	optional EntryType  Type  = 1 [(gogoproto.nullable) = false];
	optional bytes      Data  = 4;
}

The panic is emitted from the golangproto table marshaling code, which is
unexpected to me.

The raftpb package is also using gogoproto, so I don't understand why. It must be some kind of version incompatibility; it doesn't panic from within the upstream repo.

This seems like a time bomb, so we should investigate.

To Reproduce

See the unit test added in #63298.

Expected behavior

Stringers should string :-)

Additional data / screenshots

Environment:

  • master at time of writing

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions