Skip to content

Commit

Permalink
fix(inbound): always return health objects with error set (#2352)
Browse files Browse the repository at this point in the history
(cherry picked from commit f4ac1e8)
  • Loading branch information
chillleader authored and github-actions[bot] committed Apr 30, 2024
1 parent 868ff8f commit fb95ccf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package io.camunda.connector.runtime.inbound.executable;

import io.camunda.connector.api.inbound.Health;
import io.camunda.connector.api.inbound.Health.Error;
import io.camunda.connector.api.inbound.ProcessElement;
import io.camunda.connector.runtime.core.config.InboundConnectorConfiguration;
import io.camunda.connector.runtime.core.inbound.InboundConnectorDetails;
Expand Down Expand Up @@ -268,13 +269,16 @@ private ActiveExecutableResponse mapToResponse(UUID id, RegisteredExecutable con
id,
null,
failed.data().connectorElements(),
Health.down("reason", failed.reason()),
Health.down(new Error("Activation failure", failed.reason())),
List.of());
case ConnectorNotRegistered ignored -> new ActiveExecutableResponse(
case ConnectorNotRegistered notRegistered -> new ActiveExecutableResponse(
id,
null,
ignored.data().connectorElements(),
Health.down("reason", "Connector not registered"),
notRegistered.data().connectorElements(),
Health.down(
new Error(
"Activation failure",
"Connector " + notRegistered.data().type() + " not registered")),
List.of());
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,8 @@ public static Health down(Error error) {
return new Health(Status.DOWN, error, null);
}

public static Health down(String key, Object value) {
return Health.status(Status.DOWN).detail(key, value);
}

public static Health down(Map<String, Object> details) {
return Health.status(Status.DOWN).details(details);
}

public static Health down(Error error, Map<String, Object> details) {
return Health.status(Status.DOWN).details(details);
return new Health(Status.DOWN, error, details);
}

public static Health down(Throwable ex) {
Expand All @@ -131,7 +123,7 @@ interface DetailsStep {
public static class Builder implements DetailsStep {
private final Health.Status status;
private Map<String, Object> details;
private Error error;
private final Error error;

private Builder(Status status, Error error) {
this.status = status;
Expand Down

0 comments on commit fb95ccf

Please sign in to comment.