-
Notifications
You must be signed in to change notification settings - Fork 24.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rethrow script compilation exceptions into ingest configuration exceptions #19318
Conversation
return templateService.compile(propertyValue); | ||
} catch (Exception e) { | ||
throw ConfigurationUtils.newConfigurationException(processorType, processorTag, propertyName, e.getMessage()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why lose the original exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't lose the original exception. It's already difficult enough to debug script exceptions without them being swallowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thought I could re-use some headers configuration stuff and enough information would make its way through the current exception's message
def1617
to
5c6bbef
Compare
LGTM |
String propertyValue, TemplateService templateService) { | ||
try { | ||
return templateService.compile(propertyValue); | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand this code path correctly, this converts every exception thrown during template compilation into an ElasticsearchParseException
and I'm not comfortable with that. For example, it means bugs in compilation get converted into a parse exception that sounds like the user can correct? What's the reasoning here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we've been using ElasticsearchParseException
as the exception container for all our pipeline build-time configuration exceptions.
it means bugs in compilation get converted into a parse exception that sounds like the user can correct
why would the user not be able to correct these exceptions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why would the user not be able to correct these exceptions?
Because I'm specifically referring to exceptions being thrown because of bugs in the compilation explicitly not due to the user's template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I guess I am not familiar with such exceptions. If all such exceptions extend ElasticsearchException
then I suppose there is no real need to wrap the exception, but instead just add the appropriate ingest headers. So, I can check for whether an ElasticsearchException
is thrown and simply add the headers and pass it along. If other exceptions are thrown, I would need to wrap it in some sort of ElasticsearchException
so that I can relay the proper headers to the user. what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't safely say that all such exceptions will extend ElasticsearchException
(e.g., a bad NullPointerException
), but I like your idea of wrapping the ones that do not extend (as long as it's not wrapping it in an exception that sounds like the user can do something about it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasontedor Would using ExceptionsHelper#convertToElastic(...)
helper method in ConfigurationUtils#newConfigurationException(...)
or similar here be sufficient?
I think the excepting being thrown if the mustache template couldn't be compiled is a MustacheException
, which gets wrapped by GeneralScriptException
in ScriptService#compileInternal(...)
, which is what also should be fixed. Instead the lang-mustache should catch MustacheException
exceptions with ScriptException
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would using
ExceptionsHelper#convertToElastic(...)
helper method inConfigurationUtils#newConfigurationException(...)
or similar here be sufficient?
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update to use this helper. didn't know about it
5c6bbef
to
adf3890
Compare
Currently, mustache compile exceptions in pipelines are reported as regular ES exceptions, e.g.
This makes it difficult to gather which property in the pipeline configuration is causing this exception. This PR wraps these exceptions in ElasticsearchParseException so that we can relay the information