knative / client-contrib

Community contributed `kn` plugins.
Apache License 2.0
10 stars 23 forks source link

[source-kafka] Describe fails with runtime error if sink is not set #61

Open navidshaikh opened 4 years ago

navidshaikh commented 4 years ago

Create a kafka source without sink and try describing it, it fails with runtime error as the nil check for Sink is missing:

Steps to reproduce:

  1. Create kafka source

    kn source kafka create mykafkasrc --servers my-cluster-kafka-bootstrap.kafka.svc:9092 --topics test-topic --consumergroup test-consumer-group
  2. Describe it

    
    kn source kafka describe mykafkasrc
    Name:              mykafkasrc
    Namespace:         default
    Age:               3h
    BootstrapServers:  my-cluster-kafka-bootstrap.kafka.svc:9092
    Topics:            test-topic
    ConsumerGroup:     test-consumer-group

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x134ad18]

goroutine 1 [running]: knative.dev/client-contrib/plugins/source-kafka/pkg/factories.writeSink(0x184c360, 0xc00042dc50, 0x0)

[...]

Error: exit status 2 Run 'kn --help' for usage



## Suggested fix:
Check for nil value here
https://github.com/knative/client-contrib/blob/49864fb4817d265b15564a4d43cd80bbd364db55/plugins/source-kafka/pkg/factories/rune_factory.go#L189
daisy-ycguo commented 4 years ago

/assign