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 jira error parsing #39204
fix jira error parsing #39204
Conversation
Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
integrations/access/jira/types.go
Outdated
func (e ErrorResult) Error() string { | ||
sb := strings.Builder{} | ||
if len(e.ErrorMessages) > 0 { | ||
sb.WriteString(fmt.Sprintf("error messages: %s ", e.ErrorMessages)) |
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: Should we maybe string.Join(e.ErrorMessages, ";")
or something like this here?
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 always find those hard to read when multiple error happen, I'd prefer JSON-style array for those, which is done natively by Sprintf %s.
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 not sure about the error messages format (do they include some punctuation?), but adding a join char should help with readability.
Otherwise we might end up with a long string without knowing where a particular ErrorMessage starts and where it ends
Eg
V=[issue invalid format error]
using join=issue invalid; format error
Co-authored-by: Roman Tkachenko <roman@goteleport.com>
@@ -131,7 +131,7 @@ func NewJiraClient(conf JiraConfig, clusterName, teleportProxyAddr string, statu | |||
if resp.IsError() { | |||
switch result := resp.Error().(type) { | |||
case *ErrorResult: | |||
return trace.Errorf("http error code=%v, errors=[%v]", resp.StatusCode(), strings.Join(result.ErrorMessages, ", ")) | |||
return trace.Errorf("http error code=%v, errors=[%s]", resp.StatusCode(), result) | |||
case nil: | |||
return nil | |||
default: |
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.
If the error is >399 (resp.IsError()==true
), does it make sense to return nil if no error is defined?
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 think this should be unreachable, but I'm quite afraid of breaking something 😓 . It feels like this was added on purpose. Maybe for the "request cancelled" kind of issues.
integrations/access/jira/types.go
Outdated
func (e ErrorResult) Error() string { | ||
sb := strings.Builder{} | ||
if len(e.ErrorMessages) > 0 { | ||
sb.WriteString(fmt.Sprintf("error messages: %s ", e.ErrorMessages)) |
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 not sure about the error messages format (do they include some punctuation?), but adding a join char should help with readability.
Otherwise we might end up with a long string without knowing where a particular ErrorMessage starts and where it ends
Eg
V=[issue invalid format error]
using join=issue invalid; format error
@hugoShaka See the table below for backport results.
|
Fixes #38231
Changelog: Make the Jira access plugin log Jira errors properly.