Skip to content

catch processor/pipeline factory exceptions and return structured error responses#16276

Merged
talevy merged 1 commit intoelastic:masterfrom
talevy:more_details_factory_factory
Jan 29, 2016
Merged

catch processor/pipeline factory exceptions and return structured error responses#16276
talevy merged 1 commit intoelastic:masterfrom
talevy:more_details_factory_factory

Conversation

@talevy
Copy link
Copy Markdown
Contributor

@talevy talevy commented Jan 27, 2016

fixes: #16010

@talevy talevy added review v5.0.0-alpha1 :Distributed/Ingest Node Execution or management of Ingest Pipelines labels Jan 27, 2016
@talevy talevy changed the title catch processor/pipeline factory exceptions and return structured error responses [WIP] catch processor/pipeline factory exceptions and return structured error responses Jan 27, 2016
@talevy talevy added the WIP label Jan 27, 2016
@talevy talevy changed the title [WIP] catch processor/pipeline factory exceptions and return structured error responses catch processor/pipeline factory exceptions and return structured error responses Jan 27, 2016
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe SimulatePipelineResponse can just hold a PipelineFactoryError field? Then this would work and be simple?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that would work. I don't know why, but yesterday I felt like having this field that is not always applicable to be really confusing. but it would definitely work and be less refactoring

@talevy talevy force-pushed the more_details_factory_factory branch 4 times, most recently from 3a84221 to 79f3632 Compare January 29, 2016 06:34
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should include e here, otherwise we lose the cause of the configuration error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add e.getMessage() to the string, good catch!

@talevy talevy force-pushed the more_details_factory_factory branch from 5cb3dc9 to 200674b Compare January 29, 2016 20:50
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rename to validatePipelineResponse?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I'll update to that. still feels like a weird method in general... but it works

@martijnvg
Copy link
Copy Markdown
Member

Left two small comments. OTT LGTM

@talevy talevy force-pushed the more_details_factory_factory branch 2 times, most recently from 0a4a3af to 5ac974e Compare January 29, 2016 21:11
@talevy talevy force-pushed the more_details_factory_factory branch from 5ac974e to ed4a8ea Compare January 29, 2016 21:14
When there is an exception thrown during pipeline creation within
Rest calls (in put pipeline, and simulate) We now return a structured
error response to the user with details around which processor's
configuration is the cause of the issue, or which configuration property
is misconfigured, etc.
@talevy talevy force-pushed the more_details_factory_factory branch from ed4a8ea to fca442f Compare January 29, 2016 21:37
talevy added a commit that referenced this pull request Jan 29, 2016
catch processor/pipeline factory exceptions and return structured error responses
@talevy talevy merged commit 6e91d65 into elastic:master Jan 29, 2016
@talevy talevy deleted the more_details_factory_factory branch January 29, 2016 21:44
@s1monw
Copy link
Copy Markdown
Contributor

s1monw commented Feb 1, 2016

@talevy @martijnvg I think this PR should be reverted and we should use out existing exception infrastructure for this. You can set headers on all ElasticsearchExceptions that get's rendered in a strucutred way. There is no reason to add so much custom code we have a streamlined way to do this.

you can just do something like this:

try {
 // configure
} catch (Exception ex) {
 ElasticsearchException e = new ElasticsearchException("failed to configure pipeline", ex);
 e.addHeader("processor", "grok");
 e.addHeader("what_have_you", "boom");
  throw e;
}

this will get rendered as:

{
  "type" : "exception",
  "reason" : "failed to configure pipeline",
  "caused_by" : {
    "type" : "illegal_argument_exception",
    "reason" : "something is wrong"
  },
  "header" : {
    "what_have_you" : "boom",
    "processor" : "grok"
  }
}

@talevy
Copy link
Copy Markdown
Contributor Author

talevy commented Feb 1, 2016

interesting, I was not familiar with this header functionality. thanks for the suggestion!

do we want to do this. shall I preserve the ConfigurationPropertyException and then wrap this during the same time that we have all the PipelineFactoryError logic? that would really clean up that level, you're right. I'll start off with that, and we can push it down further if that is suitable.

@martijnvg
Copy link
Copy Markdown
Member

do we want to do this. shall I preserve the ConfigurationPropertyException and then wrap this during the same time that we have all the PipelineFactoryError logic? that would really clean up that level, you're right. I'll start off with that, and we can push it down further if that is suitable.

Discussed this we only throw SearchParseException and add headers from the processors and ConfigurationUtils. The PipelineFactoryError logic and ConfigurationPropertyException are no longer needed.

@s1monw
Copy link
Copy Markdown
Contributor

s1monw commented Feb 1, 2016

@martijnvg I think ElasticsearchParseException is what we should throw

@s1monw
Copy link
Copy Markdown
Contributor

s1monw commented Feb 1, 2016

oh and @talevy @martijnvg by reverting I mean not back it out just use the existing mechanism. :)

thanks

@martijnvg
Copy link
Copy Markdown
Member

@martijnvg I think ElasticsearchParseException is what we should throw

Agreed ElasticsearchParseException is better otherwise we're forced to pass down null arguments.

@talevy
Copy link
Copy Markdown
Contributor Author

talevy commented Feb 1, 2016

confirming here that I am working on migrating to ElasticsearchParseException! thanks

@talevy
Copy link
Copy Markdown
Contributor Author

talevy commented Feb 1, 2016

PR for this fix can be found here: #16355

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Distributed/Ingest Node Execution or management of Ingest Pipelines >enhancement v5.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Ingest] Add more descriptive pipeline factory errors in _simulate and PUT pipeline/id

4 participants