Skip to content

Panic index out of range when receiving message from eventhub #250

Open
@buicongtan1997

Description

I found this loc is not check len of msg.Data which causing panic: runtime error: index out of range [0] with length 0 when receiving message from eventhub

return newEvent(msg.Data[0], msg)

Expected Behavior

It can run properly

Actual Behavior

│ panic: runtime error: index out of range [0] with length 0
│ goroutine 105 [running]:
│ github.com/Azure/azure-event-hubs-go/v3.eventFromMsg(...)
│     /go/pkg/mod/github.com/!azure/azure-event-hubs-go/v3@v3.3.17/event.go:217
│ github.com/Azure/azure-event-hubs-go/v3.(*receiver).handleMessage(0xc0004b4000, 0x1815dd0, 0xc0000c4940, 0xc00063e2d0, 0xc0006b80a0)
│     /go/pkg/mod/github.com/!azure/azure-event-hubs-go/v3@v3.3.17/receiver.go:251 +0x75f
│ github.com/Azure/azure-event-hubs-go/v3.(*receiver).handleMessages(0xc0004b4000, 0x1815dd0, 0xc0000c4940, 0xc0002de900, 0xc0006b80a0)
│     /go/pkg/mod/github.com/!azure/azure-event-hubs-go/v3@v3.3.17/receiver.go:243 +0x106
│ created by github.com/Azure/azure-event-hubs-go/v3.(*receiver).Listen
│     /go/pkg/mod/github.com/!azure/azure-event-hubs-go/v3@v3.3.17/receiver.go:227 +0x18c

Environment

  • OS: alpine
  • Go version: 1.16
  • Version of Library: v3.3.17

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions