-
Notifications
You must be signed in to change notification settings - Fork 82
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
Fix error when raw error is retrieved #2079
Fix error when raw error is retrieved #2079
Conversation
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.
lgtm
} | ||
|
||
// try decoding detailed error by default | ||
detailedError := &ErrorT{} |
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: maybe?
var detailedError ErrorT
@@ -66,12 +74,77 @@ var ( | |||
ErrIndexNotFound = errors.New("index not found") | |||
ErrTimeout = errors.New("timeout") | |||
ErrNotFound = errors.New("not found") | |||
|
|||
knownErrorTypes = [3]string{ |
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: could omit the size (easier to add more elements later without updating the size)
knownErrorTypes = [...]string{
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestErrorTranslation(t *testing.T) { |
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.
👍
What is the problem this PR solves?
Enrollment or any other operation fails when error returned by elastic is a raw string instead of json
How does this PR solve the problem?
This PR adds ability to parse error either as a ErrorT type or string as a secondary option.
For string it tries to guess error type based on some well known occurrences of Exception names or error messages in retrieved error message.
How to test this PR locally
Disable
detailed_errors
in ES and try everything works.Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Related issues
Fixes: elastic/elastic-agent#931