This is an automated email from the ASF dual-hosted git repository. dominikriemer pushed a commit to branch show-better-errors-in-runtime-config in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit cea0c72717838df25f5cbb93ebb8eec2f5c40e90 Author: Dominik Riemer <[email protected]> AuthorDate: Fri Jul 3 10:02:29 2026 +0200 feat: Improve error messages shown for runtime-resolvable static properties --- .../remote/ContainerProvidedOptionsHandler.java | 29 +++++++++++++++++++--- .../rest/impl/ContainerProvidedOptions.java | 14 ++++++++--- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/remote/ContainerProvidedOptionsHandler.java b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/remote/ContainerProvidedOptionsHandler.java index 32badb4040..1b54cfb76a 100644 --- a/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/remote/ContainerProvidedOptionsHandler.java +++ b/streampipes-pipeline-management/src/main/java/org/apache/streampipes/manager/remote/ContainerProvidedOptionsHandler.java @@ -18,6 +18,8 @@ package org.apache.streampipes.manager.remote; import org.apache.streampipes.commons.exceptions.NoServiceEndpointsAvailableException; +import org.apache.streampipes.commons.exceptions.SpConfigurationException; +import org.apache.streampipes.commons.exceptions.SpRuntimeException; import org.apache.streampipes.manager.api.extensions.ExtensionServiceRequestManager; import org.apache.streampipes.manager.api.extensions.ExtensionServiceRequestTarget; import org.apache.streampipes.manager.api.extensions.ExtensionServiceRequestTargets; @@ -32,6 +34,7 @@ import org.apache.streampipes.serializers.json.JacksonSerializer; import org.apache.streampipes.svcdiscovery.api.model.SpServiceUrlProvider; import com.google.gson.JsonSyntaxException; +import org.apache.http.HttpStatus; import java.io.IOException; import java.util.Set; @@ -47,7 +50,8 @@ public class ContainerProvidedOptionsHandler { this.resourceManager = resourceManager; } - public RuntimeOptionsResponse fetchRemoteOptions(RuntimeOptionsRequest request) { + public RuntimeOptionsResponse fetchRemoteOptions(RuntimeOptionsRequest request) + throws SpConfigurationException, SpRuntimeException { try { var payload = JacksonSerializer.getObjectMapper().writeValueAsString(request); @@ -56,10 +60,19 @@ public class ContainerProvidedOptionsHandler { var response = extensionRequestManager.request( ExtensionServiceRequests.containerProvidedOptions(requestTarget, payload, authToken) ); - return handleResponse(response.responseBody()); + + if (response.isSuccess()) { + return handleResponse(response.responseBody()); + } else if (response.statusCode() == HttpStatus.SC_BAD_REQUEST) { + throw handleConfigurationError(response.responseBody()); + } else { + throw new SpRuntimeException( + "Could not resolve runtime options, status code: " + response.statusCode()); + } + } catch (SpConfigurationException | SpRuntimeException e) { + throw e; } catch (Exception e) { - e.printStackTrace(); - return new RuntimeOptionsResponse(); + throw new SpRuntimeException("Could not resolve runtime options", e); } } @@ -67,6 +80,14 @@ public class ContainerProvidedOptionsHandler { return JacksonSerializer.getObjectMapper().readValue(responseBody, RuntimeOptionsResponse.class); } + private SpConfigurationException handleConfigurationError(String responseBody) throws IOException { + var exception = JacksonSerializer + .getObjectMapper() + .readValue(responseBody, SpConfigurationException.class); + + return new SpConfigurationException(exception.getMessage(), exception.getCause()); + } + private ExtensionServiceRequestTarget getEndpointRequestTarget(String appId) throws NoServiceEndpointsAvailableException { SpServiceUrlProvider provider = ExtensionsServiceEndpointUtils.getPipelineElementType(appId); diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/ContainerProvidedOptions.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/ContainerProvidedOptions.java index b74c155537..2508aee15e 100644 --- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/ContainerProvidedOptions.java +++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/ContainerProvidedOptions.java @@ -17,10 +17,12 @@ */ package org.apache.streampipes.rest.impl; +import org.apache.streampipes.commons.exceptions.SpConfigurationException; +import org.apache.streampipes.commons.exceptions.SpRuntimeException; import org.apache.streampipes.manager.api.extensions.ExtensionServiceRequestManager; import org.apache.streampipes.manager.remote.ContainerProvidedOptionsHandler; +import org.apache.streampipes.model.monitoring.SpLogMessage; import org.apache.streampipes.model.runtime.RuntimeOptionsRequest; -import org.apache.streampipes.model.runtime.RuntimeOptionsResponse; import org.apache.streampipes.resource.management.SpResourceManager; import org.apache.streampipes.rest.core.base.impl.AbstractRestResource; @@ -48,7 +50,13 @@ public class ContainerProvidedOptions extends AbstractRestResource { produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE ) - public ResponseEntity<RuntimeOptionsResponse> fetchRemoteOptions(@RequestBody RuntimeOptionsRequest request) { - return ok(containerProvidedOptionsHandler.fetchRemoteOptions(request)); + public ResponseEntity<?> fetchRemoteOptions(@RequestBody RuntimeOptionsRequest request) { + try { + return ok(containerProvidedOptionsHandler.fetchRemoteOptions(request)); + } catch (SpConfigurationException e) { + return badRequest(SpLogMessage.from(e)); + } catch (SpRuntimeException e) { + return serverError(SpLogMessage.from(e)); + } } }
