Skip to content

Commit c7bf245

Browse files
authored
fix: do not call topic attribute func on empty topics (#660)
franz-go can create fake fetch in case of errors prevent passing an empty topic name Closes #656
1 parent bd5fa81 commit c7bf245

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

kafka/consumer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,10 @@ func (c *Consumer) fetch(ctx context.Context) error {
393393
fetches.EachError(func(t string, p int32, err error) {
394394
topicName := strings.TrimPrefix(t, c.consumer.topicPrefix)
395395
logger := c.cfg.Logger
396-
if c.cfg.TopicLogFieldFunc != nil {
396+
// franz-go can inject fake fetches in case of errors.
397+
// the fake fetch can have an empty topic so we need to
398+
// account for that
399+
if c.cfg.TopicLogFieldFunc != nil && topicName != "" {
397400
logger = logger.With(c.cfg.TopicLogFieldFunc(topicName))
398401
}
399402

0 commit comments

Comments
 (0)