Skip to content

Stop returning "es." internal exception headers as http response headers#22703

Merged
javanna merged 4 commits intoelastic:masterfrom
javanna:enhancement/stop_returning_es_exception_headers
Jan 24, 2017
Merged

Stop returning "es." internal exception headers as http response headers#22703
javanna merged 4 commits intoelastic:masterfrom
javanna:enhancement/stop_returning_es_exception_headers

Conversation

@javanna
Copy link
Copy Markdown
Contributor

@javanna javanna commented Jan 19, 2017

Move "es." internal headers to separate metadata set in ElasticsearchException and stop returning them as response headers. These headers are printed out as part of the response body already, they weren't meant to be sent back as response headers too. They were introduced to prevent having to add custom exceptions to our codebase whenever we need to throw an exception that has to hold some additional metadata that ElasticsearchException doesn't support out of the box. The header notion stays in ElasticsearchException but only for what actually needs to be returned as response header (no "es." prefix).

Also removed ESExceptionTests and moved its tests under ElasticsearchExceptionTests or ExceptionSerializationTests

Closes #17593

@javanna javanna requested a review from tlrx January 19, 2017 21:23
@javanna javanna force-pushed the enhancement/stop_returning_es_exception_headers branch from 3817f0d to 2bc7547 Compare January 19, 2017 21:26
@javanna javanna requested a review from jaymode January 19, 2017 21:26
Copy link
Copy Markdown
Member

@tlrx tlrx left a comment

Choose a reason for hiding this comment

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

Thanks @javanna, I think this is heading in the right direction. I left some minor comments but we still need to figure out what to do with the TODOs :)

I do like the move of internal headers es.* to exception metadata and I share your concerns about serializing back a parsed exception... but that shouldn't happen, neither in core nor in the high level rest client.

For a long term, I think we should also drop the metadataToXcontent() method which can lead to name conflicts in the rendered xcontent and also adds confusion if we add a metadata class attribute.

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 remove "instead" from the exception message?

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.

Yes, I changed it in #22675

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.

ok I will remove the TODO then

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.

I think it's OK here because the token is a value, not an array. But later in the loop we need to take care of arrays.

I think we can already do it for values and just ignore objects for now

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.

Are we testing this somewhere?

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.

this line is duplicated

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.

good catch

@javanna
Copy link
Copy Markdown
Contributor Author

javanna commented Jan 20, 2017

For a long term, I think we should also drop the metadataToXcontent() method which can lead to name conflicts in the rendered xcontent and also adds confusion if we add a metadata class attribute.

that's correct, I think that the problem is that those additional fields are printed at the same level as the metadata (previous es. headers). They should rather be in a different object that only subclasses can write, but that is a breaking change. That said I am not sure how many clients are able to parse our exceptions entirely given how difficult we made it for them :)

@javanna
Copy link
Copy Markdown
Contributor Author

javanna commented Jan 23, 2017

@s1monw mind having a look too?

Copy link
Copy Markdown
Contributor

@s1monw s1monw left a comment

Choose a reason for hiding this comment

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

LGTM

@javanna javanna force-pushed the enhancement/stop_returning_es_exception_headers branch from 17ab7eb to 95b9979 Compare January 24, 2017 11:41
@javanna javanna added >bug and removed >enhancement labels Jan 24, 2017
@javanna javanna force-pushed the enhancement/stop_returning_es_exception_headers branch from 95b9979 to ea0ee3b Compare January 24, 2017 12:51
@javanna javanna merged commit 47c0e13 into elastic:master Jan 24, 2017
javanna added a commit that referenced this pull request Jan 24, 2017
…ers (#22703)

move "es." internal headers to separate metadata set in ElasticsearchException and stop returning them as response headers

Closes #17593

* [TEST] remove ESExceptionTests, move its methods to ElasticsearchExceptionTests or ExceptionSerializationTests
s1monw added a commit that referenced this pull request Jan 26, 2017
We added version dependent serialziation in #22703 which triggers a bug in
LocalTransport that misses to set the serializatoin version when an exception
is serialized. This is only relevant for tests since local transport has by-definition
the same version on both ends in production.

Closes #22784
s1monw added a commit that referenced this pull request Jan 26, 2017
We added version dependent serialziation in #22703 which triggers a bug in
LocalTransport that misses to set the serializatoin version when an exception
is serialized. This is only relevant for tests since local transport has by-definition
the same version on both ends in production.

Closes #22784
s1monw added a commit that referenced this pull request Jan 26, 2017
We added version dependent serialziation in #22703 which triggers a bug in
LocalTransport that misses to set the serializatoin version when an exception
is serialized. This is only relevant for tests since local transport has by-definition
the same version on both ends in production.

Closes #22784
@lcawl lcawl added the :Core/Infra/Core Core issues without another label label Feb 13, 2018
@lcawl lcawl removed the :Exceptions label Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop returning additional HTTP headers on exceptions

5 participants