Skip to content

Search Commits API Results Problem #601

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

Closed
amirilovic opened this issue Mar 28, 2017 · 11 comments
Closed

Search Commits API Results Problem #601

amirilovic opened this issue Mar 28, 2017 · 11 comments
Labels

Comments

@amirilovic
Copy link
Contributor

Issue: When calling search commits api (go-github/github/search.go:84) returned results contain correct number of items but each item properties are empty.

As per github search docs https://developer.github.com/v3/search/#search-commits

Search Commits is returning results as:

{
  "total_count": 1,
  "incomplete_results": false,
  "items": [
    {
      "url": "https://api.github.com/repos/octocat/Spoon-Knife/commits/bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f",
      "sha": "bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f",
      "html_url": "https://github.com/octocat/Spoon-Knife/commit/bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f",
      "comments_url": "https://api.github.com/repos/octocat/Spoon-Knife/commits/bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f/comments",
      "commit": {
        "url": "https://api.github.com/repos/octocat/Spoon-Knife/git/commits/bb4cc8d3b2e14b3af5df699876dd4ff3acd00b7f",
        "author": {
          "date": "2014-02-04T14:38:36-08:00",
          "name": "The Octocat",
          "email": "octocat@nowhere.com"
        },
        "committer": {
          "date": "2014-02-12T15:18:55-08:00",
          "name": "The Octocat",
          "email": "octocat@nowhere.com"
        },
        "message": "Create styles.css and updated README",
        "tree": {
          "url": "https://api.github.com/repos/octocat/Spoon-Knife/git/trees/a639e96f9038797fba6e0469f94a4b0cc459fa68",
          "sha": "a639e96f9038797fba6e0469f94a4b0cc459fa68"
        },
        "comment_count": 8
      },
      "author": {
        // author fields ...
      },
      "committer": {
       // committer fields ...
      },
      "parents": [
        {
          "url": "https://api.github.com/repos/octocat/Spoon-Knife/commits/a30c19e3f13765a3b48829788bc1cb8b4e95cee4",
          "html_url": "https://github.com/octocat/Spoon-Knife/commit/a30c19e3f13765a3b48829788bc1cb8b4e95cee4",
          "sha": "a30c19e3f13765a3b48829788bc1cb8b4e95cee4"
        }
      ],
      "repository": {
       // repo fields ...
      },
      "score": 4.9971514
    }
  ]
}

But in search.go:67 results are deserialized in CommitResult struct which has different layout:

type CommitResult struct {
	Hash           *string     `json:"hash,omitempty"`
	Message        *string     `json:"message,omitempty"`
	AuthorID       *int        `json:"author_id,omitempty"`
	AuthorName     *string     `json:"author_name,omitempty"`
	AuthorEmail    *string     `json:"author_email,omitempty"`
	AuthorDate     *Timestamp  `json:"author_date,omitempty"`
	CommitterID    *int        `json:"committer_id,omitempty"`
	CommitterName  *string     `json:"committer_name,omitempty"`
	CommitterEmail *string     `json:"committer_email,omitempty"`
	CommitterDate  *Timestamp  `json:"committer_date,omitempty"`
	Repository     *Repository `json:"repository,omitempty"`
}

So, returned results are empty.

@dmitshur
Copy link
Member

dmitshur commented Mar 29, 2017

This issue seems valid. Any ideas how this happened?

It looks like CommitResult was added recently, just 2 months ago in #520. /cc @sahildua2305 @gmlewis It's a preview API, announced at https://developer.github.com/changes/2017-01-05-commit-search-api/. Has it changed since back then, or did we make a mistake in #520?

I just want to understand what happened better (in order to learn from it, and to be more confident this is a valid issue; not looking to place blame on anyone, making mistakes is okay, they can be fixed once spotted and understood).

I've looked through https://developer.github.com/changes/ and not spotting any changes. So my current best guess is that we made a mistake when reviewing #520 and this was never correct.

Or perhaps GitHub did change the preview API, but didn't announce that (or maybe their docs page had a mistake that they've since fixed).

The q search term docs seem to have fields that match the current CommitResult, perhaps that's what was used by mistake?

image

(From https://developer.github.com/v3/search/#search-commits.)

But it doesn't have them all, so perhaps not.

Any additional insight is welcome. Of course, it's not neccessary to figure this out, but I think it'd be helpful, if possible.

@dmitshur dmitshur added the bug label Mar 29, 2017
@amirilovic
Copy link
Contributor Author

@shurcooL My reasoning exactly the same. I've tried to find if docs have changed in the meantime on https://web.archive.org/web/20170301000000*/https://developer.github.com/v3/search but there is now history for January 2017.

@aleksclark
Copy link
Contributor

aleksclark commented Mar 29, 2017

@gmlewis / @shurcooL I'd like to work on this if that's acceptable :) Also, is mentioning a maintainer needed generally? If so I'll submit a docs PR, if not I'll stop doing it

@sahildua2305
Copy link
Member

Indeed, @shurcooL, it's weird to have this broken without any documented change from GitHub.

@amirilovic
Copy link
Contributor Author

@aleksclark I've already submitted a pull request #602

@aleksclark
Copy link
Contributor

@amirilovic facepalm of course I noticed that about 20 seconds before your comment. nevermind :P

@gmlewis
Copy link
Collaborator

gmlewis commented Mar 29, 2017

Yes, very odd, but this looks like the correct way to proceed. Thanks, all, for catching and fixing this.

@gmlewis
Copy link
Collaborator

gmlewis commented Mar 31, 2017

@shurcooL - should #602 have bumped the libraryVersion number?
I'm thinking now that it should have. Thoughts?

@dmitshur
Copy link
Member

dmitshur commented Mar 31, 2017

Yes, it should've. The Go API has changed. It's done to match the GitHub API, but it's still a breaking API change.

It's fine to do so in a followup commit. Maybe even bundle a few changes into one version bump.

@gmlewis
Copy link
Collaborator

gmlewis commented Mar 31, 2017

OK, we have a few PRs in the queue. Let's get it bumped shortly. I won't create a new PR just for the bump.

@dmitshur
Copy link
Member

Bumped it in 5b3f96e.

bubg-dev pushed a commit to bubg-dev/go-github that referenced this issue Jun 16, 2017
…oogle#602)

Fix issue with commit search results deserialization

Fixes google#601.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants