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

Added Repository Collaborators API. #34

Closed
wants to merge 3 commits into from

Conversation

wlynch
Copy link
Contributor

@wlynch wlynch commented Aug 8, 2013

Issue #33: Implementation for Repository Collaborators API.

return false, nil, err
}
resp, err := s.client.Do(req, nil)
if resp.StatusCode == 204 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

use parseBoolResponse() here, since it includes some special handling of 404 responses.

Copy link
Collaborator

Choose a reason for hiding this comment

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

optionally, we could update parseBoolResponse() to explicitly look for 204 responses to indicate success. However, then I'm not sure what to do when receiving a non-204 response that also doesn't return an error (for example, any other 2** response code). Of course, that should never happen, but still worth coding against. As parseBoolResponse() is written today, a 200 response would still return true. I think that's probably okay.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only issue I can see here is the fact that 404 can be returned in 2 instances:

  1. The user is not a collaborator.
  2. The user does not exist.

The only way to tell these apart is through the error message Github returns. parseBoolResponse() will not return the error on a 404, so we would have no way of determining the reason of failure. Do we care about making a distinction between the two?

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, interesting. I hadn't noticed that there actually are different error messages for those two different cases. Sadly, there's not a reliable machine readable way to distinguish between the two (parsing the error message feels too brittle). I'll look and see if this is true for the other methods as well, in which case we should probably update parseBoolResponse() to account for this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

so none of the other methods I tested distinguish between a standard false response, and a false response because the requested resource doesn't exist. I think the fact that this method actually distinguishes between these is a fluke, so I'm not too worried about it. If we think anyone will care, I think I'd rather update parseBoolResponse() to suppress the 404 response if the error message is an exact match to the string "Not Found", and return it otherwise. But again, I don't think it's worth doing at this point. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that we shouldn't modify parseBoolResponse. Like you said, this seems to be a special edge case and not applicable anywhere else. The API docs also make no mention of this difference in 404's, so I think we're safe to treat them both as the same.

Plus if a user is not on GitHub then they are obviously not a collaborator on a project.

@willnorris
Copy link
Collaborator

merged as b00b4e1

@willnorris willnorris closed this Aug 13, 2013
adrien-barret pushed a commit to adrien-barret/go-github that referenced this pull request Jan 15, 2024
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.

None yet

2 participants