-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Consistent errors for GetRef when a Ref doesn't exist #1207
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
Conversation
Fixes #1208 |
This is fine with me. What do you think, @gauntface ? If we do this, I believe it would fall under the category of a "minor" semver change... meaning that we would bump the middle number. It doesn't break any existing clients because it still returns an error, but the error response does change. If @gauntface is fine with this change, then LGTM. |
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 a fan of two scenarios using the same error message, would be good to make it clear why each error is thrown.
github/git_refs.go
Outdated
@@ -69,6 +69,9 @@ func (s *GitService) GetRef(ctx context.Context, owner string, repo string, ref | |||
if _, ok := err.(*json.UnmarshalTypeError); ok { | |||
// Multiple refs, means there wasn't an exact match. | |||
return nil, resp, errors.New("no exact match found for this ref") |
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.
Could we change the error message to "multiple matches found for this ref"?
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.
Done
github/git_refs.go
Outdated
@@ -69,6 +69,9 @@ func (s *GitService) GetRef(ctx context.Context, owner string, repo string, ref | |||
if _, ok := err.(*json.UnmarshalTypeError); ok { | |||
// Multiple refs, means there wasn't an exact match. | |||
return nil, resp, errors.New("no exact match found for this ref") | |||
} else if resp.StatusCode == 404 { | |||
// No ref, there was no match for the ref | |||
return nil, resp, errors.New("no exact match found for this ref") |
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.
Could we change this to "no match found for this ref"?
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.
Done
Codecov Report
@@ Coverage Diff @@
## master #1207 +/- ##
==========================================
+ Coverage 73.39% 73.39% +<.01%
==========================================
Files 84 84
Lines 5949 5951 +2
==========================================
+ Hits 4366 4368 +2
Misses 825 825
Partials 758 758
Continue to review full report at Codecov.
|
@gauntface Yep that sounds sensible have fixed up this PR. |
Thank you, @gauntface and @pilbot ! |
No description provided.