Go function panic due to non-canonical topic
- Dominant language
- Java
- Stars
- 15.3k
- Forks
- 3.8k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 142
Description
**Describe the bug**
When creating a go function with an input topic name that is non-canonical (e.g. `public/default/input`), the function panics due to different topic names being used.
**To Reproduce**
Steps to reproduce the behavior:
1. Create a go function with input topic `public/default/input`.
2. Publish a message to the topic
3. Watch for panic in the logs.
**Expected behavior**
No panic
**Screenshots**
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x8d8103]
goroutine 14 [running]:
github.com/apache/pulsar/pulsar-function-go/pf.(*goInstance).ackInputMessage(0xc0000c6640, 0xb29040, 0xc0016543c0)
/home/phemmer/.go/src/github.com/apache/pulsar/pulsar-function-go/pf/instance.go:301 +0x73
github.com/apache/pulsar/pulsar-function-go/pf.(*goInstance).processResult.func1(0xb16ea0, 0xc000096bc0, 0xc00168c090, 0x0, 0x0)
/home/phemmer/.go/src/github.com/apache/pulsar/pulsar-function-go/pf/instance.go:291 +0xf4
github.com/apache/pulsar-client-go/pulsar.(*partitionProducer).ReceivedSendReceipt(0xc0004cc140, 0xc000096b40)
/home/phemmer/.go/src/github.com/apache/pulsar-client-go/pulsar/producer_partition.go:432 +0x260
github.com/apache/pulsar-client-go/pulsar/internal.(*connection).handleSendReceipt(0xc001598120, 0xc000096b40)
/home/phemmer/.go/src/github.com/apache/pulsar-client-go/pulsar/internal/connection.go:518 +0xfe
github.com/apache/pulsar-client-go/pulsar/internal.(*connection).internalReceivedCommand(0xc001598120, 0xc0004cb180, 0x0, 0x0)
/home/phemmer/.go/src/github.com/apache/pulsar-client-go/pulsar/internal/connection.go:437 +0x1ce
github.com/apache/pulsar-client-go/pulsar/internal.(*connection).run(0xc001598120)
/home/phemmer/.go/src/github.com/apache/pulsar-client-go/pulsar/internal/connection.go:325 +0x304
github.com/apache/pulsar-client-go/pulsar/internal.(*connection).start.func1(0xc001598120)
/home/phemmer/.go/src/github.com/apache/pulsar-client-go/pulsar/internal/connection.go:195 +0x59
created by github.com/apache/pulsar-client-go/pulsar/internal.(*connection).start
/home/phemmer/.go/src/github.com/apache/pulsar-client-go/pulsar/internal/connection.go:192 +0x3f
```
^ from version 2.5.0
**Additional context**
The issue in this panic is because [`ackInputMessage()`](https://github.com/apache/pulsar/blob/v2.5.1/pulsar-function-go/pf/instance.go#L263) is using the topic name `persistent://public/default/input`. However [`setupConsumer()`](https://github.com/apache/pulsar/blob/v2.5.1/pulsar-function-go/pf/instance.go#L220) is using `public/default/input`.
This canonicalization could be done by the go library prior to storing in the `gi.consumers` map. However I think it would be more appropriate for the topic name to be canonicalized before passing to the go application as an argument, as this canonicalization should apply to all languages.
Contributor guide
Research direction
Start in pulsar-function-go/pf/instance.go, comparing setupConsumer() around line 220 with ackInputMessage() around line 263 and the processResult path. Trace how topic names reach the go application and gi.consumers, then verify that a non-canonical input such as public/default/input no longer causes a panic and is handled consistently across supported function languages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100