smallrye-reactive-messaging icon indicating copy to clipboard operation
smallrye-reactive-messaging copied to clipboard

Bootstrap servers parsing fails

Open JoranBergfeld opened this issue 3 years ago • 8 comments

Description When providing a kafka.bootstrap.servers property wrapped in quotation marks, parsing fails with an error message stating the bootstrap server is invalid. I'm very aware that this is a small quality of life change, but it would be great that either way, you do not encounter this issue.

Environment

Java:

> java -version
openjdk version "19-ea" 2022-09-20
OpenJDK Runtime Environment (build 19-ea+28-2110)
OpenJDK 64-Bit Server VM (build 19-ea+28-2110, mixed mode, sharing)

Quarkus BOM: 2.10.3.Final

Example

kafka.bootstrap.servers="joran-tes-cbbd-tuej----kjigoug.bf2.kafka.rhcloud.com:443"

Fails with parsing.

kafka.bootstrap.servers=joran-tes-cbbd-tuej----kjigoug.bf2.kafka.rhcloud.com:443

Parses correctly.

JoranBergfeld avatar Jul 20 '22 11:07 JoranBergfeld

I suppose we could remove the first and last ". @ozangunalp WDYT?

cescoffier avatar Jul 20 '22 11:07 cescoffier

I wonder if smallrye config provides an interceptor for stripping " from values.

ozangunalp avatar Jul 20 '22 11:07 ozangunalp

ah yes, @radcortez ?

cescoffier avatar Jul 20 '22 12:07 cescoffier

What is the failure exactly? Is it the parsing at the Kafka config layer?

The issue is that we cannot arbitrarily remove quotations from configuration values because we don't know if the user intended them to be there or not. It is possible to write an interceptor to do such operations to specific keys, but it would need to be registered on the consumer side (in this case, RM).

Do you want me to add one?

radcortez avatar Jul 21 '22 00:07 radcortez

Failure isn't a big deal, in all honesty. It just causes some confusion, as the bootstrap URL is correct. However, the quotation marks indeed interfere with the class org.apache.kafka.clients.ClientUtils, so it's the Kafka layer. I'd probably expect us to sanitise the string before passing it to the Kafka layer. It would improve developer experience a small bit, in my view.

JoranBergfeld avatar Jul 21 '22 07:07 JoranBergfeld

The bootstrap servers should not be wrapped in quotes (Kafka rejects it). I believe we should sanitize on our side as the "key" of the bootstrap server can be the global one, the channel one, or the connector one. The channel one is unknown for MP Config.

cescoffier avatar Jul 21 '22 07:07 cescoffier

Isn't this the case for every config property? For exemple if you pass value.serializer="org.apache.kafka.common.serialization.StringSerializer" config you'd get a ClassNotFoundException.

ozangunalp avatar Jul 21 '22 11:07 ozangunalp

An alternative could be to use a @ConfigMapping interface and add specific converters to each property.

radcortez avatar Jul 21 '22 17:07 radcortez

We cannot add specific converters, the set of properties is open.

cescoffier avatar Apr 28 '23 13:04 cescoffier

Closing - unfortunately, not easy solution - except make sure to not wrap the values with "

cescoffier avatar Apr 28 '23 13:04 cescoffier