octokit.net
octokit.net copied to clipboard
Auditing API response fields
We've had a number of issues raised where users have found certain fields provided by the GitHub API arent implemented in Octokit.net (mostly due to historic reasons). We have also found on more than one occasion that fields are included in Json payload responses that aren't necessarily shown in the official GitHub API docs.
I thought it would be interesting to add some trace logging to highlight any fields which are received in API responses that we don't have a matching Octokit field for, and ran as many integration tests as I could.
This is the full unaltered list... Many items in the list should likely remain un-implemented, but there could be some useful/interesting or simply overlooked fields in here. I thought I would post the results and anyone interested could highlight fields they think should be implemented in Octokit.net
Octokit.ActivityPayload
actiondescriptionmaster_branchmemberpagespusher_typerefref_typerelease
Octokit.ApiError
error
Octokit.ApiErrorDetail
value
Octokit.ApplicationAuthorization
appupdated_atuser
Octokit.Author
gravatar_id
Octokit.Authorization
apptokenupdated_at
Octokit.AuthorizedManagementKey
pretty-print
Octokit.Blob
url
Octokit.BlobReference
url
Octokit.Branch
_linksprotected
Octokit.CombinedCommitStatus
commit_urlurl
Octokit.Commit
distincthtml_url
Octokit.Committer
avatar_urlevents_urlfollowers_urlfollowing_urlgists_urlgravatar_idhtml_urlidloginorganizations_urlreceived_events_urlrepos_urlsite_adminstarred_urlsubscriptions_urltypeurl
Octokit.Deployment
environmentrefrepository_urltask
Octokit.DeploymentStatus
deployment_urlrepository_url
Octokit.EventInfo
commit_url
Octokit.Gist
commits_urlforks_urltruncateduser
Octokit.GistFile
truncated
Octokit.GistFork
commentscomments_urlcommits_urldescriptionfilesforks_urlgit_pull_urlgit_push_urlhtml_urlidownerpublicupdated_at
Octokit.GitReference
authorcomments_urlcommitcommitterhtml_urlparents
Octokit.Issue
labels_urlrepository_urlscore
Octokit.IssueComment
issue_url
Octokit.License
conditionslimitationspermissions
Octokit.LicenseMetadata
featured
Octokit.Migration
archive_urlowner
Octokit.Milestone
html_urlidlabels_urlupdated_at
Octokit.Organization
billing_emaildescriptionevents_urlgravatar_idhooks_urlissues_urlmembers_urlpublic_members_urlrepos_urlupdated_at
Octokit.PublicKey
created_atread_onlyverified
Octokit.PullRequest
_linkscomments_urlcommits_urlidmerge_commit_shamergeable_statemergedreview_comment_urlreview_commentsreview_comments_url
Octokit.PullRequestReviewComment
_links
Octokit.PushEventPayload
beforedistinct_sizepush_id
Octokit.ReadmeResponse
_linksdownload_urlgit_urlpathshasizetype
Octokit.Repository
archive_urlassignees_urlblobs_urlbranches_urlcollaborators_urlcomments_urlcommits_urlcompare_urlcontents_urlcontributors_urldeployments_urldownloads_urlevents_urlforksforks_urlgit_commits_urlgit_refs_urlgit_tags_urlhas_pageshooks_urlissue_comment_urlissue_events_urlissues_urlkeys_urllabels_urllanguages_urlmerges_urlmilestones_urlnetwork_countnotifications_urlopen_issuesorganizationpublicpulls_urlreleases_urlscoresizestargazers_urlstatuses_urlsubscribers_countsubscribers_urlsubscription_urltags_urlteams_urltrees_urlwatcherswatchers_count
Octokit.RepositoryContent
_links
Octokit.RepositoryContentInfo
_links
Octokit.RepositoryContributor
gravatar_id
Octokit.RepositoryHook
last_responsetype
Octokit.SearchCode
score
Octokit.Team
descriptionmembers_urlprivacyrepositories_urlslug
Octokit.User
display_loginevents_urlfollowers_urlfollowing_urlgists_urlgravatar_idgravatar_idorganizations_urlreceived_events_urlrepos_urlscorestarred_urlsubscriptions_urlupdated_at
+1
Is there any progress on getting some of these fields added? I'm currently having to work around the non-existent "before" field in PushEventPayload, for example.
@Norbo11 no progress per se, this wasn't a list of things to implement as many of them aren't desired/required (due to being API url fields or previously deprecated fields etc).
It's great you've found one that should be added! would you consider sending a PR to include it?
Thanks
Sure, I can do that at some point this week. Also, I was wondering why, when accessing the Events API, the "deleted" field is not included in PushEvent payloads. I'm not talking about Octokit in particular, I mean the actual Events API payload, which I assumed would return the same payload as the event delivered through i.e. a web hook?
I'm not sure what the actual reason is for that upstream API behaviour/design but I do see multiple references in the API docs saying that the push event is specifically different payload between the webhook and the events API
https://developer.github.com/webhooks/#payloads https://developer.github.com/v3/activity/events/types/#pushevent
I guess that confirms its expected behaviour but if you wanted your know WHY you could perhaps try contacting github support and asking?
Okay, thanks a lot, I'll see what I can find.
We were looking at using the distinct field on commits specifically (to cut down on processing). There's a bit of weirdness there in that it's on the webhook commit response, but not on the GET /commit response, and as best I can tell OctoKit uses the same model for both. Would that be a nullable bool (seems easier to add from a 'I could make a PR for this' standpoint)? Or would it need to be split out into two models, one for commits from the API & one for commits from a webhook payload?
How different are the response payloads? Would be great if you could post an example commit json response from both cases so we can see how many fields aren't returned.
You're right in that generally we use the same model for the same thing (eg a PullRequest) eventhough some API responses (eg a GetAll type request) don't include all of the fields that are returned from a single object Get request.
It sounds reasonable to make this field nullable (and perhaps any others that are in the same boat) rather than splitting out a new object model, unless there are heaps of discrepancies
I compared what I get from a saved webhook (push event vs from the api) and added the results/diff in a gist.
Key points:
- webhook uses
Id, commit usesSha - webhook has lists of files affected, api does not (and requires generating a diff)
- webhook his a
distinctfield, commit doesn't (which makes sense givendistinctis only valid at that point in time) - api has info about the tree/parents of the commit, and the webhook doesn't
(It turns out that I had actually been using a reimplemented model locally which was how I've been parsing pushes in the first place).
I think the worst difference is that it uses different property names to refer to the same thing - like id vs sha.
Maybe we should consider adding an attribute to properties that contain mappings of potential names for the deserializer. For example,
[OtherNames("sha")]
Public string ID {get} ;
Although this will only work if the type is the same
so , how do we do these missing fields? any plans?
Hi @niltor,
There aren't any plans to add every extra field en-masse because some of them could be being deprecated and so on...
But certainly if anyone comes across a field that is provided by the API but not defined in octokit.net it can be added to the response models via a pull request. Is there a particular missing field you've encountered?
@ryangribble ok,got it.
Deployment.Environment would be useful to have. My use case is the user can rename an enviroment and I want to reflect it in the API.
Deployment.Environment would be useful to have
@Cyberboss see https://github.com/octokit/octokit.net/pull/2560
Closing this issue, given many of these resources are now present in the current SDK. Please open new issues for other needs.