Skip to content
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

Improved error message fallback logic #35

Merged
merged 5 commits into from
Mar 12, 2020
Merged

Improved error message fallback logic #35

merged 5 commits into from
Mar 12, 2020

Conversation

tadam313
Copy link
Contributor

@tadam313 tadam313 commented Mar 3, 2020

Hi @joshdk! We came across an issue when junit XML failure report contains message but no meaningful body in it. In that scenario we'd ideally use the message as a fallback or type to display the error rather than the "empty" body. I've created a PR to address it, also open for any suggestion/requests, happy to discuss this further :)

@tadam313 tadam313 closed this Mar 3, 2020
@tadam313 tadam313 reopened this Mar 3, 2020
@tadam313 tadam313 changed the title [WEB-3486] fallback error serialization logic Error serialization logic refinement Mar 3, 2020
@tadam313 tadam313 changed the title Error serialization logic refinement Failure serialization logic refinement Mar 3, 2020
@tadam313
Copy link
Contributor Author

tadam313 commented Mar 3, 2020

also lint failed during dependency fetch however I don't have permission to re-run it, can you please do that @joshdk?

Copy link
Owner

@joshdk joshdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tadam313 👋

Thank you for your contribution! (and for finding edge-cases in the wild) Overall looks fine, left 2 minor comments.

Additionally, I'm going to look into the lint failure; I retriggered the lint stage, and it failed in the same way (but I don't think it's related to anything you committed). It's probably due to how we're go get-ing golangci-lint.

Cheers!

types.go Outdated Show resolved Hide resolved
testdata/fastlane-trainer.xml Outdated Show resolved Hide resolved
@tadam313 tadam313 requested a review from joshdk March 5, 2020 07:53
@tadam313
Copy link
Contributor Author

tadam313 commented Mar 6, 2020

@joshdk I believed, addressed every comments, can you please take another look?

types.go Outdated
if strings.TrimSpace(err.Type) != "" {
return err.Type
}

return err.Body
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the very end, do you want to return err.Type with no check? The value of err.Body is guaranteed to be blank (or at best all whitespace characters) by this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, my thinking was "try all the fields, if everything is still empty then return Body". In this case we can maintain backward compatibility, since so far only Body was used. I'm not sure if we need to change that behaviour. WDYT @joshdk ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since err.Body is both the first thing (preferably) returned, and the fallback, it will be blank in the latter case. Concretely, I was thinking of something like:

switch {
    case strings.TrimSpace(err.Body) != "":
        return err.Body

    case strings.TrimSpace(err.Message) != "":
        return err.Message

    default:
        return err.Type
}

There isn't really a way to maintain data back-compat in this case (as the function can possibly return more than just that single value now), but I would be fine with the above refactor 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all right, sounds good to me 👍

types.go Outdated Show resolved Hide resolved
@joshdk
Copy link
Owner

joshdk commented Mar 6, 2020

@tadam313 please rebase your fork off of master to pick up #36 🙂

@joshdk
Copy link
Owner

joshdk commented Mar 11, 2020

Any thoughts, or things I can help with @tadam313? Cheers!

@tadam313
Copy link
Contributor Author

@joshdk all good, sorry just been busy in last few days, but I did the modifications you requested, also rebased on master thanks fixing the dependency issue 👍

@tadam313 tadam313 requested a review from joshdk March 12, 2020 14:45
Copy link
Owner

@joshdk joshdk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tadam313 for your contribution! 🎉

@joshdk joshdk changed the title Failure serialization logic refinement Improved error message fallback logic Mar 12, 2020
@joshdk joshdk merged commit e5d93c0 into joshdk:master Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants