Skip to content

Commit

Permalink
Clean up expression error messages, allow - in json pointer in condit…
Browse files Browse the repository at this point in the history
…ional expressions

Signed-off-by: Taylor Gray <[email protected]>
  • Loading branch information
graytaylor0 committed Oct 17, 2024
1 parent dce5388 commit 22301fe
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ JsonPointerCharacters

fragment
JsonPointerCharacter
: [A-Za-z0-9_.@]
: [A-Za-z0-9_.@\-]
;

EscapedJsonPointer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ public AggregateProcessor(final AggregateProcessorConfig aggregateProcessorConfi
pluginMetrics.gauge(CURRENT_AGGREGATE_GROUPS, aggregateGroupManager, AggregateGroupManager::getAllGroupsSize);

if (aggregateProcessorConfig.getWhenCondition() != null && (!expressionEvaluator.isValidExpressionStatement(aggregateProcessorConfig.getWhenCondition()))) {
throw new InvalidPluginConfigurationException("aggregate_when {} is not a valid expression statement. See https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/ for valid expression syntax");
throw new InvalidPluginConfigurationException(
String.format("aggregate_when \"%s\" is not a valid expression statement. See https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/ for valid expression syntax",
aggregateProcessorConfig.getWhenCondition()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ public DateProcessor(PluginMetrics pluginMetrics, final DateProcessorConfig date
extractKeyAndFormatters();

if (dateProcessorConfig.getDateWhen() != null && (!expressionEvaluator.isValidExpressionStatement(dateProcessorConfig.getDateWhen()))) {
throw new InvalidPluginConfigurationException("date_when {} is not a valid expression statement. See https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/ for valid expression syntax");
throw new InvalidPluginConfigurationException(
String.format("date_when \"%s\" is not a valid expression statement. See https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/ for valid expression syntax",
dateProcessorConfig.getDateWhen()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public DissectProcessor(PluginMetrics pluginMetrics, final DissectProcessorConfi

if (dissectConfig.getDissectWhen() != null &&
(!expressionEvaluator.isValidExpressionStatement(dissectConfig.getDissectWhen()))) {
throw new InvalidPluginConfigurationException("dissect_when {} is not a valid expression statement. See https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/ for valid expression syntax");
throw new InvalidPluginConfigurationException(
String.format("dissect_when \"%s\" is not a valid expression statement. See https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/ for valid expression syntax",
dissectConfig.getDissectWhen()));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public FlattenProcessor(final PluginMetrics pluginMetrics, final FlattenProcesso

if (config.getFlattenWhen() != null &&
(!expressionEvaluator.isValidExpressionStatement(config.getFlattenWhen()))) {
throw new InvalidPluginConfigurationException("flatten_when {} is not a valid expression statement. See https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/ for valid expression syntax");
throw new InvalidPluginConfigurationException(
String.format("flatten_when \"%s\" is not a valid expression statement. See https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/ for valid expression syntax",
config.getFlattenWhen()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ public GeoIPProcessor(final PluginMetrics pluginMetrics,

if (geoIPProcessorConfig.getWhenCondition() != null &&
(!expressionEvaluator.isValidExpressionStatement(geoIPProcessorConfig.getWhenCondition()))) {
throw new InvalidPluginConfigurationException("geoip_when {} is not a valid expression statement. See https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/ for valid expression syntax");
throw new InvalidPluginConfigurationException(
String.format("geoip_when \"%s\" is not a valid expression statement. See https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/ for valid expression syntax",
geoIPProcessorConfig.getWhenCondition()));
}

this.geoIPProcessorService = geoIpConfigSupplier.getGeoIPProcessorService().orElseThrow(() ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ public GrokProcessor(final PluginMetrics pluginMetrics,

if (grokProcessorConfig.getGrokWhen() != null &&
(!expressionEvaluator.isValidExpressionStatement(grokProcessorConfig.getGrokWhen()))) {
throw new InvalidPluginConfigurationException("grok_when {} is not a valid expression statement. See https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/ for valid expression syntax");
throw new InvalidPluginConfigurationException(
String.format("grok_when \"%s\" is not a valid expression statement. See https://opensearch.org/docs/latest/data-prepper/pipelines/expression-syntax/ for valid expression syntax",
grokProcessorConfig.getGrokWhen()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ public static IndexConfiguration readIndexConfig(final PluginSetting pluginSetti

builder = builder.withVersionExpression(versionExpression);
if (versionExpression != null && (!expressionEvaluator.isValidFormatExpression(versionExpression))) {
throw new InvalidPluginConfigurationException("document_version {} is not a valid format expression.");
throw new InvalidPluginConfigurationException(
String.format("document_version \"%s\" is not a valid format expression.", versionExpression));
}

builder = builder.withVersionType(versionType);
Expand Down

0 comments on commit 22301fe

Please sign in to comment.