Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak ConfigNotFoundException class #4821

Merged
merged 4 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public interface Configs {

String getAirbyteVersion();

String getAirbyteApiUrl();

int getAirbyteApiPort();

String getAirbyteVersionOrWarning();

Path getConfigRoot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class EnvConfigs implements Configs {

public static final String AIRBYTE_ROLE = "AIRBYTE_ROLE";
public static final String AIRBYTE_VERSION = "AIRBYTE_VERSION";
public static final String INTERNAL_API_HOST = "INTERNAL_API_HOST";
public static final String WORKER_ENVIRONMENT = "WORKER_ENVIRONMENT";
public static final String WORKSPACE_ROOT = "WORKSPACE_ROOT";
public static final String WORKSPACE_DOCKER_MOUNT = "WORKSPACE_DOCKER_MOUNT";
Expand Down Expand Up @@ -91,6 +92,16 @@ public String getAirbyteRole() {
return getEnv(AIRBYTE_ROLE);
}

@Override
public String getAirbyteApiUrl() {
return getEnsureEnv(INTERNAL_API_HOST).split(":")[0];
}

@Override
public int getAirbyteApiPort() {
return Integer.parseInt(getEnsureEnv(INTERNAL_API_HOST).split(":")[1]);
}

@Override
public String getAirbyteVersion() {
return getEnsureEnv(AIRBYTE_VERSION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,24 @@

public class ConfigNotFoundException extends Exception {

private ConfigSchema type;
private final String type;
private final String configId;

public ConfigNotFoundException(ConfigSchema type, String configId) {
public ConfigNotFoundException(String type, String configId) {
super(String.format("config type: %s id: %s", type, configId));
this.type = type;
this.configId = configId;
}

public ConfigNotFoundException(ConfigSchema type, String configId) {
this(type.toString(), configId);
}

public ConfigNotFoundException(ConfigSchema type, UUID uuid) {
this(type, uuid.toString());
this(type.toString(), uuid.toString());
}

public ConfigSchema getType() {
public String getType() {
return type;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static InvalidInputExceptionInfo infoFromConstraints(ConstraintViolationE
props.add(new InvalidInputProperty()
.propertyPath(cv.getPropertyPath().toString())
.message(cv.getMessage())
.invalidValue(cv.getInvalidValue().toString()));
.invalidValue(cv.getInvalidValue() != null ? cv.getInvalidValue().toString() : "null"));
}
exceptionInfo.validationErrors(props);
return exceptionInfo;
Expand Down