Skip to content

Commit 7db6ef7

Browse files
Fix exposed connector URL in error message (opensearch-project#3953) (opensearch-project#3961)
* Fix exposed connector URL in error message * Fix failing test * spotless apply --------- (cherry picked from commit d46a49f) Signed-off-by: rithin-pullela-aws <rithinp@amazon.com> Co-authored-by: Rithin Pullela <rithinp@amazon.com>
1 parent 17ac86e commit 7db6ef7

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

common/src/main/java/org/opensearch/ml/common/connector/Connector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ default void validateConnectorURL(List<String> urlRegexes) {
182182
}
183183
}
184184
if (!hasMatchedUrl) {
185-
throw new IllegalArgumentException("Connector URL is not matching the trusted connector endpoint regex, URL is: " + url);
185+
throw new IllegalArgumentException("Connector URL is not matching the trusted connector endpoint regex");
186186
}
187187
}
188188
}

common/src/main/java/org/opensearch/ml/common/connector/McpConnector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ public void validateConnectorURL(List<String> urlRegexes) {
438438
}
439439
}
440440
if (!hasMatchedUrl) {
441-
throw new IllegalArgumentException("Connector URL is not matching the trusted connector endpoint regex, URL is: " + url);
441+
throw new IllegalArgumentException("Connector URL is not matching the trusted connector endpoint regex");
442442
}
443443
}
444444

plugin/src/test/java/org/opensearch/ml/action/connector/TransportCreateConnectorActionTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,7 @@ public void test_execute_URL_notMatchingExpression_exception() {
546546
action.doExecute(task, request, actionListener);
547547
ArgumentCaptor<Exception> argumentCaptor = ArgumentCaptor.forClass(Exception.class);
548548
verify(actionListener).onFailure(argumentCaptor.capture());
549-
assertEquals(
550-
"Connector URL is not matching the trusted connector endpoint regex, URL is: https://api.openai1.com/v1/completions",
551-
argumentCaptor.getValue().getMessage()
552-
);
549+
assertEquals("Connector URL is not matching the trusted connector endpoint regex", argumentCaptor.getValue().getMessage());
553550
}
554551

555552
public void test_connector_creation_success_deepseek() {

0 commit comments

Comments
 (0)