This is an automated email from the ASF dual-hosted git repository.

kevdoran pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 51545f6bf58 NIFI-15940: Ensure that when a 
ConnectorConfigurationProviderException is thrown during a web request it 
doesn't fall through to the ThrowableMapper. (#11250)
51545f6bf58 is described below

commit 51545f6bf5873d88de3f350559bdb99c43b8a8a7
Author: Matt Gilman <[email protected]>
AuthorDate: Thu May 14 10:16:32 2026 -0400

    NIFI-15940: Ensure that when a ConnectorConfigurationProviderException is 
thrown during a web request it doesn't fall through to the ThrowableMapper. 
(#11250)
---
 .../apache/nifi/web/NiFiWebApiResourceConfig.java  |  2 +
 ...nectorConfigurationProviderExceptionMapper.java | 45 ++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiWebApiResourceConfig.java
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiWebApiResourceConfig.java
index 978977b13f9..8eece65de4e 100644
--- 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiWebApiResourceConfig.java
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiWebApiResourceConfig.java
@@ -24,6 +24,7 @@ import 
org.apache.nifi.web.api.config.AuthenticationCredentialsNotFoundException
 import 
org.apache.nifi.web.api.config.AuthenticationNotSupportedExceptionMapper;
 import org.apache.nifi.web.api.config.AuthorizationAccessExceptionMapper;
 import org.apache.nifi.web.api.config.ClusterExceptionMapper;
+import 
org.apache.nifi.web.api.config.ConnectorConfigurationProviderExceptionMapper;
 import org.apache.nifi.web.api.config.IllegalArgumentExceptionMapper;
 import 
org.apache.nifi.web.api.config.IllegalClusterResourceRequestExceptionMapper;
 import org.apache.nifi.web.api.config.IllegalClusterStateExceptionMapper;
@@ -114,6 +115,7 @@ public class NiFiWebApiResourceConfig extends 
ResourceConfig {
         register(AuthenticationCredentialsNotFoundExceptionMapper.class);
         register(AdministrationExceptionMapper.class);
         register(ClusterExceptionMapper.class);
+        register(ConnectorConfigurationProviderExceptionMapper.class);
         register(IllegalArgumentExceptionMapper.class);
         register(IllegalClusterResourceRequestExceptionMapper.class);
         register(IllegalClusterStateExceptionMapper.class);
diff --git 
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/ConnectorConfigurationProviderExceptionMapper.java
 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/ConnectorConfigurationProviderExceptionMapper.java
new file mode 100644
index 00000000000..fff4fc22aac
--- /dev/null
+++ 
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/config/ConnectorConfigurationProviderExceptionMapper.java
@@ -0,0 +1,45 @@
+/*
+ * 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.nifi.web.api.config;
+
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.ext.ExceptionMapper;
+import jakarta.ws.rs.ext.Provider;
+import 
org.apache.nifi.components.connector.ConnectorConfigurationProviderException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Maps connector configuration provider exceptions into client responses. 
Provider implementations
+ * raise this exception for any failure of an external configuration operation 
(load, save, discard,
+ * delete, asset management, etc.). The framework cannot classify the failure 
further without
+ * coupling to a specific provider implementation, so a generic Internal 
Server Error response is
+ * returned with the provider-supplied message in the response body so callers 
can surface it
+ * directly.
+ */
+@Provider
+public class ConnectorConfigurationProviderExceptionMapper implements 
ExceptionMapper<ConnectorConfigurationProviderException> {
+
+    private static final Logger logger = 
LoggerFactory.getLogger(ConnectorConfigurationProviderExceptionMapper.class);
+
+    @Override
+    public Response toResponse(final ConnectorConfigurationProviderException 
exception) {
+        logger.warn("{}. Returning {} response.", exception, 
Response.Status.INTERNAL_SERVER_ERROR, exception);
+        return 
Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(exception.getMessage()).type("text/plain").build();
+    }
+
+}

Reply via email to