Skip to content

Commit

Permalink
TEMPORARY FIX: add check if header is missing in inAddErrorToResponse…
Browse files Browse the repository at this point in the history
…Header
  • Loading branch information
VjeraTurk committed Nov 13, 2024
1 parent b0a7839 commit 382d2c6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/messaging/response_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ func (h *evmResponseHandler) HandleRequest(_ context.Context, msgType types.Mess
func (h *evmResponseHandler) AddErrorToResponseHeader(response protoreflect.ProtoMessage, errMessage string) {
headerFieldDescriptor := response.ProtoReflect().Descriptor().Fields().ByName("header")
headerReflectValue := response.ProtoReflect().Get(headerFieldDescriptor)

if !headerReflectValue.IsValid() || !headerReflectValue.Message().IsValid() {
// TODO: @VjeraTurk support more than 1 version! Or ensure header is not nil elsewhere
// Initialize the header if it is not set
header := &typesv1.ResponseHeader{}
response.ProtoReflect().Set(headerFieldDescriptor, protoreflect.ValueOfMessage(header.ProtoReflect()))
addErrorToResponseHeaderV1(header, errMessage)
return
}

switch header := headerReflectValue.Message().Interface().(type) {
case *typesv1.ResponseHeader:
addErrorToResponseHeaderV1(header, errMessage)
Expand Down

0 comments on commit 382d2c6

Please sign in to comment.