Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Adds new SavedObjectsRespository error type for 404 that do not originate from Elasticsearch responses #107301
Adds new SavedObjectsRespository error type for 404 that do not originate from Elasticsearch responses #107301
Changes from 6 commits
81d435d
98a785f
7c52b54
e173b77
5614cda
7d00fdd
e45920d
449dda6
b20e9c2
0befcbd
9ab33bb
987c941
dc5dc67
0edd561
b9955ae
35cf9d0
81d7571
9cbbb57
4b9bfc0
e720a62
55aabbf
2af49d3
2f76296
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
under what circumstances can they be
null
?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.
Good question! This PR only adds the checks to
get
,update
anddelete
, all of which require atype
andid
.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've made
type
andid
required for this PR.They would be
null
if we were to implementcreateGenericNotFoundEsUnavailableError
when thex-product-elasticsearch
header is missing or has the wrong value in the response fromopenPointInTimeForType
:Before:
After:
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.
Copied self-review comment:
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.
Do we need this API? If we want plugins to treat this error as any other ES not found issue, I think it'd be ok to only include the factory function
createGenericNotFoundEsUnavailableError
so that plugins don't waste time trying to figure out how they should handle this error in a different way.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 actually using the API within the repository to verify error types here. It also ensures we stay consistent with repository error type checks, such as
isNotFoundError
, with the additional check on the error reason.isNotFoundEsUnavailableError
isn't an error itself, it returns a boolean.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.
Right, but as a plugin developer, I'd want to handle each error exposed on
SavedObjectsErrorHelpers.is*
in order to make my code bulletproof. I'd expect that each of theseis*Error
methods to only correspond to one error type and not overlap, but now that is no longer the case since bothisEsUnavailableError
andisNotFoundEsUnavailableError
could return true on the same error. I'd also expect that each error type would correspond to something different I could do to handle this, however the underlying problem for both of these errors is the same and there's really nothing different I can/should do as a developer for theisNotFoundEsUnavailableError
case vs theisEsUnavailable
one.Are you planning to add similar new error guards for each method as part of #107343? Personally, I think we should only expose
isEsUnavailable
for all of these situations to signal to plugins that they should handle this error in the same way for every method.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.
That makes sense. I've removed
isNotFoundEsUnavailableError
.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.
Copied self-review comment: