Get not allowed error, Unable to create topic list watcher: Pattern longer than maximum: 50
- Dominant language
- Java
- Stars
- 15.3k
- Forks
- 3.8k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 160
Description
### Search before asking
- [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.
### Motivation
I have topics that are very long: about 100 characters. The regex matcher cannot handle this apparently.
```
var patternStr = topic + ".*"
val topicPattern: Pattern = Pattern.compile(patternStr)
pulsarConsumer = consumerBuilder.topicsPattern(topicPattern).subscribe()
```
=> [pulsar-client-io-1-3] ERROR org.apache.pulsar.client.impl.ClientCnx - Get not allowed error, Unable to create topic list watcher: Pattern longer than maximum: 50
If I try to shorten the topic pattern and only use the last 50 or so characters, this is also not allowed:
```
var patternStr = topic + ".*"
if (topic.length > 46) {
patternStr = ".*" + topic.slice(topic.length - 46..topic.length - 1) + ".*"
logger.info("Using shortened topic regex matcher: $patternStr")
}
val topicPattern: Pattern = Pattern.compile(patternStr)
pulsarConsumer = consumerBuilder.topicsPattern(topicPattern).subscribe()
```
=>
````
Exception in thread "main" org.apache.pulsar.client.api.PulsarClientException: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Invalid short topic name '.*place513/consumption-metamagic542153-coverage-v0.*', it should be in the format of // or
at org.apache.pulsar.client.api.PulsarClientException.unwrap(PulsarClientException.java:1111)
at org.apache.pulsar.client.impl.ConsumerBuilderImpl.subscribe(ConsumerBuilderImpl.java:103)
````
### Solution
_No response_
### Alternatives
_No response_
### Anything else?
_No response_
### Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!
Contributor guide
Research direction
Reproduce the long-topic pattern cases from the issue and trace subscription handling from ConsumerBuilderImpl.java. Compare the server's 50-character pattern rejection with the client error for a shortened pattern; done requires a clearly defined and tested way to handle these long topic patterns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100