-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Improves not found response handling in the saved objects repository #108749
Improves not found response handling in the saved objects repository #108749
Conversation
* @param response response from elasticsearch client call | ||
* @returns boolean 'true' if the status code is 404 and the Elasticsearch product header is missing/unexpected value | ||
*/ | ||
export const isNotFoundFromUnsupportedServer = (args: { |
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'm in two minds about where this helper should go and considered moving it to the elasticsearch
service but went with internal_utils
as we're really only using it within the SO service right now.
I'm also open to suggestions for the name (naming is hard...)!
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.
FWIW, I don't have strong feelings one way or the other on whether this is internal or in the ES service. If it was used anywhere else I'd say put it in the ES service though.
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 moved the method since we're both thinking it should belong to the elasticsearch
service. While ATM it's only used in the SO service, other folks might have to implement something similar.
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.
Overall makes sense! Couple thoughts & questions.
* @param response response from elasticsearch client call | ||
* @returns boolean 'true' if the status code is 404 and the Elasticsearch product header is missing/unexpected value | ||
*/ | ||
export const isNotFoundFromUnsupportedServer = (args: { |
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.
FWIW, I don't have strong feelings one way or the other on whether this is internal or in the ES service. If it was used anywhere else I'd say put it in the ES service though.
src/core/server/saved_objects/service/lib/internal_utils.test.ts
Outdated
Show resolved
Hide resolved
elasticsearchClientMock.createSuccessTransportRequestPromise( | ||
{ ...response }, | ||
{ statusCode: 404 }, | ||
{} |
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.
nit: If we aren't including the ES product header here, might be worth renaming this function for clarity so that it is obvious it is specific to only one type of error?
Or I guess alternatively you could attempt to make it more generic by, say, adding an expectedErrorResult
as in bulkCreateError
and conditionally exluding the header if the error is a genericNotFoundEsUnavailableError
Same nit applies to bulkGetMgetError
and bulkUpdateMgetError
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.
might be worth renaming this function for clarity so that it is obvious it is specific to only one type of error
I went with the renaming option (e.g. https://github.com/elastic/kibana/pull/108749/files#diff-8a58e602e79e19512cd392387f38a79ba9782f60d0fc1596a90d5e9e18efb6bdR655) to make it super clear!
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.
Updates LGTM
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
💔 Backport failed
Successful backport PRs will be merged automatically after passing CI. To backport manually run: |
…108749) (#108954) Co-authored-by: Christiane (Tina) Heiligers <[email protected]>
Resolves #107343
This PR is to address the follow up on #107301, and verifies that 404 responses are from ES in the remaining saved object repository APIs where we explicitly
ignore
404
and handle the error ourselves.If the check fails, we throw a decorated
EsUnavailableError
instead ofNot Found
.Checklist
Risk Matrix
x-elastic-product
header .For maintainers