sdk-go
sdk-go copied to clipboard
Nil pointer exception after NewEvent with invalid version.
If, say,event := cloudevents.NewEvent("2.0")
is used to make event
and then event.SetType("foo")
is called, this causes a nil pointer exception because the internal context is nil.
I would expect to be able to call the convenience methods on event without NPE on an event that the NewEvent
method made. I might not expect that event to be sendable by the client. But I do want to assemble it and then look at the validation errors.
QQ: What if NewEvent()
would do a validation against a supported set of versions instead? This would require an API change though :/
In general I'd +1 on retrieving a non-nil context and let the validation helpers do their job.