-
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
Fixes bugs for product check in update and delete #109979
Fixes bugs for product check in update and delete #109979
Conversation
@@ -69,6 +70,11 @@ export function decorateEsError(error: EsErrors) { | |||
if (match?.length > 0) { | |||
return SavedObjectsErrorHelpers.decorateIndexAliasNotFoundError(error, match[1]); | |||
} | |||
// Throw EsUnavailable error if the 404 is not from elasticsearch | |||
// Needed here to verify Product support for any non-ignored 404 responses from calls to ES |
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.
Check against the product header and return the appropriate error from here to catch it in update
.
@@ -681,6 +681,10 @@ export class SavedObjectsRepository { | |||
{ ignore: [404] } | |||
); | |||
|
|||
if (isNotFoundFromUnsupportedServer({ statusCode, headers })) { |
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.
Simplifies the nested conditionals originally added.
Pinging @elastic/kibana-core (Team:Core) |
expect(SavedObjectsErrorHelpers.isNotFoundError(error)).toBe(false); | ||
const genericError = decorateEsError(error); | ||
expect(genericError).not.toBe(error); | ||
expect(SavedObjectsErrorHelpers.isNotFoundError(error)).toBe(false); |
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: duplicated. see L117
); | ||
await expectNotFoundEsUnavailableError(type, id); | ||
await expectNotFoundError(type, id); |
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.
👍 a good catch
src/core/server/saved_objects/service/lib/decorate_es_error.test.ts
Outdated
Show resolved
Hide resolved
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
* Fixes bugs for product check in update and delete * Apply suggestions from code review
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
Summary
Adding integration tests for #107246 uncovered a couple of edge cases not handled in the original work. This PR fixes bugs in update and delete introduced in #107301.
In the original implementation for handling 404's in
delete
, we only verified that an error is from Elasticsearch whenbody.found
is explicitlynot_found
. However, that might not be the case when the error originates from the proxy itself and we'll miss those.In
update
, we don't ignore 404's and these are caught ifretryCallCluster
throws so we have to handle the product check on NotFound errors indecorateEsError
.Checklist
Delete any items that are not applicable to this PR.
Risk Matrix
Delete this section if it is not applicable to this PR.
Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.
When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:
For maintainers
(No breaking API changes)