Skip to content

Commit

Permalink
Merge pull request data-integrations#158 from cloudsufi/patch/url-val…
Browse files Browse the repository at this point in the history
…idation

[PLUGIN-1756] Fixed URL Validation
  • Loading branch information
vikasrathee-cs authored Mar 7, 2024
2 parents a52d27c + fd18c22 commit 1bd1512
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ public Schema getSchema(FailureCollector failureCollector) {
new HttpResponse(client.executeHTTP(config.getUrl())));
return DelimitedSchemaDetector.detectSchema(config, delimiter, rawStringPerLine, failureCollector);
} catch (IOException e) {
String errorMessage = e.getMessage();
if (Strings.isNullOrEmpty(errorMessage) && e.getCause() != null) {
errorMessage = e.getCause().getMessage();
}
failureCollector.addFailure(String.format("Error while reading the file to infer the schema. Error: %s",
e.getMessage()), null);
errorMessage), null);
}
return null;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import io.cdap.plugin.http.common.pagination.page.PageFormat;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -570,7 +570,7 @@ public void validate(FailureCollector failureCollector) {
if (!containsMacro(PROPERTY_URL)) {
try {
// replace with placeholder with anything just during pagination
new URI(getUrl().replaceAll(PAGINATION_INDEX_PLACEHOLDER_REGEX, "0"));
new URL(getUrl().replaceAll(PAGINATION_INDEX_PLACEHOLDER_REGEX, "0"));

// Validate HTTP Error Handling Map
if (!containsMacro(PROPERTY_HTTP_ERROR_HANDLING)) {
Expand All @@ -591,7 +591,7 @@ public void validate(FailureCollector failureCollector) {
}
}
}
} catch (URISyntaxException e) {
} catch (MalformedURLException e) {
throw new InvalidConfigPropertyException(
String.format("URL value is not valid: '%s'", getUrl()), e, PROPERTY_URL);
}
Expand Down

0 comments on commit 1bd1512

Please sign in to comment.