Skip to content

Commit 6d58954

Browse files
Use throwInvalidIndexNameException() to throw invalid ex after
dropping asterisk in `IdentifierBuilder#resolveAndValidateIndex()`
1 parent c94c021 commit 6d58954

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/parser/IdentifierBuilder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,17 +305,17 @@ private static void resolveAndValidateIndex(String index, EsqlBaseParser.IndexPa
305305
return;
306306
}
307307

308-
InvalidIndexNameException errorToThrow = e;
309308
/*
310309
* We only modify this particular message because it mentions '*' as an invalid char.
311310
* However, we do allow asterisk in the index patterns: wildcarded patterns. Let's not
312311
* mislead the user by mentioning this char in the error message.
313312
*/
314313
if (e.getMessage().contains("must not contain the following characters")) {
315-
errorToThrow = new InvalidIndexNameException(index, e.getMessage().replace("'*',", ""));
314+
var updatedInvalidChars = Strings.INVALID_FILENAME_CHARS.replace("'*',", "");
315+
throwInvalidIndexNameException(index, "must not contain the following characters " + updatedInvalidChars, ctx);
316316
}
317317

318-
throw new ParsingException(errorToThrow, source(ctx), errorToThrow.getMessage());
318+
throw new ParsingException(e, source(ctx), e.getMessage());
319319
}
320320
}
321321

0 commit comments

Comments
 (0)