Skip to content

Add the AuthorAssociation field to IssueComment and PullRequestComment. - #892

Merged
dmitshur merged 1 commit into
google:masterfrom
dsymonds:master
Apr 12, 2018
Merged

dmitshur merged 1 commit into
google:masterfrom
dsymonds:master

Conversation

@dsymonds

Copy link
Copy Markdown
Contributor

It's undocumented in the v3 API, but is present in the v4 API, and is
indeed returned in v3 API requests.

@googlebot googlebot added the cla: yes Indication that the PR author has signed a Google Contributor License Agreement. label Apr 12, 2018
@dmitshur

Copy link
Copy Markdown
Member

When we encounter inconsistencies in GitHub API v3 behavior vs its documentation, we generally try to report it to GitHub. At the very top of https://developer.github.com/v3/, they say:

This describes the resources that make up the official GitHub REST API v3. If you have any problems or requests please contact GitHub support.

That way, they can fix the documentation (if it was wrong), fix the behavior (if the documentation was accurate), and confirm to us whether something is considered official and can be relied on.

@dsymonds Would you like to contact them about it and let us know their response?

Aside from this feature being undocumented (in v3 API docs), the change looks good.

@dsymonds

Copy link
Copy Markdown
Contributor Author

I can contact them, but I suspect they'll just give some uninteresting response about how their v3 API is the past and v4 is the future, and not actually get anywhere. It's not that their documentation is wrong, per se, only incomplete, and given that almost all of their v3 API documentation is sorely lacking in completeness I'm not surprised to find the occasional missing info.

@dmitshur

dmitshur commented Apr 12, 2018 •

Copy link
Copy Markdown
Member

From past experience, they tend to be very helpful, even in a situation like this. I think it’s worth a shot.

If there’s no response for a long time, then we can consider moving forward anyway. But if they confirm those fields are meant to be included in v3 and are just missing in docs, merging this will become much easier.

Also, reporting inconsistencies generally leads to there being fewer of them, and this library is easier to maintain when it deviates less from the GitHub API docs.

Thanks for doing this.

@dsymonds

Copy link
Copy Markdown
Contributor Author

OK, I'll send them a note and report back.

@dsymonds

Copy link
Copy Markdown
Contributor Author

Looks like you were right, cool.

"Thanks for reaching out. That field is indeed meant to be in the response and the docs need to be updated. I've passed this along to the docs team so that they can look into this. "

@dmitshur dmitshur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great to hear!

I've confirmed the author_association field exists in the real GitHub API v3 response for both the objects that these 2 structs map to. So that part has my LGTM.

I have one more comment about potentially documenting the possible AuthorAssociation values, see inline comment and let me know what you think.

Comment thread github/issues_comments.go Outdated
Reactions *Reactions `json:"reactions,omitempty"`
CreatedAt *time.Time `json:"created_at,omitempty"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
AuthorAssociation *string `json:"author_association,omitempty"`

@dmitshur dmitshur Apr 12, 2018 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It might be helpful to document the possible values, ala:

AuthorAssociation *string `json:"author_association,omitempty"` // Possible values are: "COLLABORATOR", "CONTRIBUTOR", "FIRST_TIMER", "FIRST_TIME_CONTRIBUTOR", "MEMBER", "OWNER", or "NONE".

We do this in some other places, e.g.:

// Action is the action that was performed. Possible values are:
// "created", "closed", "opened", "edited", "deleted"
Action *string `json:"action,omitempty"`

The reason to do so is because GitHub API v3 docs currently don't list the possible values, so someone looking at go-github API docs will not be able to tell what the possible value for AuthorAssociation field are, other than by trial and error. That doesn't make for a friendly API.

I think it'd be okay to leave this out when GitHub updates their API v3 docs to mention the possible values for this field. So an alternative could be to hold merging this PR until then.

What do you think is better?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, I want to actually be able to use this field in my code, so I'd prefer to get this PR merged, and then return to add more documentation whenever GitHub gets to updating their docs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note also that the GitHub docs generally do a poor job of describing possible return values. They only seem to document request parameters.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I wasn't clear. I was going to add the sample values in this PR, even though they aren't in any docs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

even though they aren't in any docs.

I got the list of values from the v4 API docs (https://developer.github.com/v4/enum/commentauthorassociation/). The author_association values I saw when I tried a few sample queries against the v3 API matched that, so I expect the rest should match too.

It's undocumented in the v3 API, but is present in the v4 API, and is
indeed returned in v3 API requests.
@dsymonds

Copy link
Copy Markdown
Contributor Author

PTAL

@dmitshur dmitshur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks!

@dmitshur
dmitshur merged commit d170093 into google:master Apr 12, 2018
nbareil pushed a commit to nbareil/go-github that referenced this pull request May 1, 2018
…oogle#892)

It's currently undocumented in GitHub API v3 docs, but is present in API v4,
and is also returned in API v3 responses.

GitHub support have confirmed that the field is meant to be included
in GitHub API v3 responses, and the documentation will be updated.

It's documented in GitHub API v4 docs at
https://developer.github.com/v4/reference/object/issuecomment/#fields and
https://developer.github.com/v4/reference/enum/commentauthorassociation/.
jlaportebot added a commit to jlaportebot/go-github that referenced this pull request Jun 28, 2026
…oogle#892)

It's currently undocumented in GitHub API v3 docs, but is present in API v4,
and is also returned in API v3 responses.

GitHub support have confirmed that the field is meant to be included
in GitHub API v3 responses, and the documentation will be updated.

It's documented in GitHub API v4 docs at
https://developer.github.com/v4/reference/object/issuecomment/#fields and
https://developer.github.com/v4/reference/enum/commentauthorassociation/.
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.

3 participants