goutamadwant commented on code in PR #19202:
URL: https://github.com/apache/pinot/pull/19202#discussion_r3763804785


##########
pinot-plugins/pinot-stream-ingestion/pinot-kafka-base/src/main/java/org/apache/pinot/plugin/stream/kafka/KafkaConfigUtils.java:
##########
@@ -0,0 +1,104 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.plugin.stream.kafka;
+
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import java.util.regex.Matcher;
+import org.apache.kafka.common.config.AbstractConfig;
+import org.apache.kafka.common.config.ConfigException;
+import org.apache.kafka.common.config.ConfigTransformer;
+import org.apache.kafka.common.config.provider.FileConfigProvider;
+
+
+/// Shared helpers for preparing Kafka client configuration. The helpers are 
stateless and thread-safe.
+public class KafkaConfigUtils {
+  private static final String CONFIG_PROVIDERS_PREFIX = 
AbstractConfig.CONFIG_PROVIDERS_CONFIG + ".";
+  private static final String CONFIG_PROVIDER_CLASS_SUFFIX = ".class";
+  private static final String CONFIG_PROVIDER_PARAM_PREFIX = ".param.";
+
+  private KafkaConfigUtils() {
+  }
+
+  /// Filters properties to the target Kafka client's known configurations and 
Kafka's dynamic ConfigProvider
+  /// namespace. Kafka may still report the provider keys themselves as 
unknown after using them for resolution.
+  ///
+  /// @param properties properties to filter
+  /// @param validConfigNames configuration names recognized by the target 
Kafka client
+  /// @return a new Properties object containing the client and ConfigProvider 
settings
+  /// @throws ConfigException if a referenced provider is undeclared, has no 
class, or is a FileConfigProvider
+  /// without an allowed-path restriction
+  public static Properties filterAndValidateKafkaProperties(Properties 
properties, Set<String> validConfigNames) {
+    Properties filteredProperties = new Properties();
+    for (String key : properties.stringPropertyNames()) {
+      if (validConfigNames.contains(key) || 
key.equals(AbstractConfig.CONFIG_PROVIDERS_CONFIG)
+          || key.startsWith(CONFIG_PROVIDERS_PREFIX)) {
+        filteredProperties.put(key, properties.get(key));
+      }
+    }
+    validateConfigProviderReferences(filteredProperties);
+    return filteredProperties;
+  }
+
+  private static void validateConfigProviderReferences(Properties properties) {
+    Set<String> configuredProviders = getConfiguredProviders(properties);
+    for (String key : properties.stringPropertyNames()) {
+      Matcher matcher = 
ConfigTransformer.DEFAULT_PATTERN.matcher(properties.getProperty(key));
+      while (matcher.find()) {

Review Comment:
   Documented the stricter behavior in the companion docs branch. Embedded 
`${alias:...}` substrings require a declared provider alias and there is no 
escape for preserving them literally. This behavior now fails explicitly 
instead of allowing unresolved provider-shaped content to pass through.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to