Skip to content
Merged
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 @@ -144,7 +144,7 @@ private static CommandGenerator.ValidationResult checkResults(
);
if (outputValidation.success() == false) {
for (Pattern allowedError : ALLOWED_ERROR_PATTERNS) {
if (allowedError.matcher(outputValidation.errorMessage()).matches()) {
if (isAllowedError(outputValidation.errorMessage(), allowedError)) {
return outputValidation;
}
}
Expand All @@ -155,13 +155,24 @@ private static CommandGenerator.ValidationResult checkResults(

private void checkException(EsqlQueryGenerator.QueryExecuted query) {
for (Pattern allowedError : ALLOWED_ERROR_PATTERNS) {
if (allowedError.matcher(query.exception().getMessage()).matches()) {
if (isAllowedError(query.exception().getMessage(), allowedError)) {
return;
}
}
fail("query: " + query.query() + "\nexception: " + query.exception().getMessage());
}

/**
* Long lines in exceptions can be split across several lines. When a newline is inserted, the end of the current line and the beginning
* of the new line are marked with a backslash {@code \}; the new line will also have whitespace before the backslash for aligning.
*/
private static final Pattern ERROR_MESSAGE_LINE_BREAK = Pattern.compile("\\\\\n\\s*\\\\");

private static boolean isAllowedError(String errorMessage, Pattern allowedPattern) {
String errorWithoutLineBreaks = ERROR_MESSAGE_LINE_BREAK.matcher(errorMessage).replaceAll("");
return allowedPattern.matcher(errorWithoutLineBreaks).matches();
}

@SuppressWarnings("unchecked")
private EsqlQueryGenerator.QueryExecuted execute(String command, int depth) {
try {
Expand Down