+
Skip to content

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

Merged
merged 2 commits into from
Jul 8, 2019

Conversation

pilbot
Copy link
Contributor

@pilbot pilbot commented Jun 24, 2019

No description provided.

@googlebot googlebot added the cla: yes Indication that the PR author has signed a Google Contributor License Agreement. label Jun 24, 2019
@pilbot
Copy link
Contributor Author

pilbot commented Jun 24, 2019

Fixes #1208

@gmlewis
Copy link
Collaborator

gmlewis commented Jun 24, 2019

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.

@gmlewis gmlewis requested a review from gauntface June 24, 2019 14:12
Copy link
Contributor

@gauntface gauntface left a 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.

@@ -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")
Copy link
Contributor

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"?

Copy link
Contributor Author

@pilbot pilbot Jul 1, 2019

Choose a reason for hiding this comment

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

Done

@@ -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")
Copy link
Contributor

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"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@codecov
Copy link

codecov bot commented Jul 1, 2019

Codecov Report

Merging #1207 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
github/git_refs.go 72.52% <100%> (+0.61%) ⬆️
github/repos_comments.go 79.1% <0%> (ø) ⬆️
github/users.go 62.79% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cbe45b0...05bba03. Read the comment docs.

@pilbot
Copy link
Contributor Author

pilbot commented Jul 1, 2019

@gauntface Yep that sounds sensible have fixed up this PR.

@gmlewis
Copy link
Collaborator

gmlewis commented Jul 8, 2019

Thank you, @gauntface and @pilbot !
Merging with a bump to the minor version since the error response changes.

@gmlewis gmlewis merged commit 035bec2 into google:master Jul 8, 2019
@pilbot pilbot deleted the git-ref-errors branch July 23, 2019 10:05
n1lesh pushed a commit to n1lesh/go-github that referenced this pull request Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Indication that the PR author has signed a Google Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载