Skip to content
Open
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 @@ -180,12 +180,12 @@ public void validateLabelExpression(Action.DynamicLabel dynamicLabel) {
validKeys.add(tokenExtractionRule.getAlias());
}
});
Pattern pattern = Pattern.compile("\\{(\\\\}|[^}])*}");
Pattern pattern = Pattern.compile("\\$\\{(\\\\}|[^}])*}");
Matcher matcher = pattern.matcher(labelExpression);
int startOffset = 0;
while (startOffset < labelExpression.length() && matcher.find(startOffset)) {
String match = matcher.group();
String key = match.substring(1, match.length() - 1);
String key = match.substring(2, match.length() - 1);
startOffset = startOffset + matcher.end();
if (!validKeys.contains(key)) {
throwInvalidArgumentException("Invalid key name in label expression");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void validateLabelExpression() {
Condition.newBuilder().setLeafCondition(errorLeafCondition).build();
CreateLabelApplicationRuleRequest request1 =
buildCreateCreateLabelApplicationRuleRequest(
"Label Expression Rule", matchingCondition, Optional.of("${status}_{wrong-key}"));
"Label Expression Rule", matchingCondition, Optional.of("${status}_${wrong-key}"));
Throwable exception =
assertThrows(
StatusRuntimeException.class,
Expand All @@ -206,7 +206,7 @@ void validateLabelExpression() {
});
CreateLabelApplicationRuleRequest request2 =
buildCreateCreateLabelApplicationRuleRequest(
"Label Expression Rule", matchingCondition, Optional.of("${status}_{method}"));
"Label Expression Rule", matchingCondition, Optional.of("${status}_${method}"));
assertDoesNotThrow(
() -> {
labelApplicationRuleValidator.validateOrThrow(REQUEST_CONTEXT, request2);
Expand Down