Skip to content

Change head.repo on pull requests to Option #97

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 1 commit into from
Jul 15, 2019

Conversation

ashawley
Copy link
Contributor

Pull requests can have their forks deleted:

This means the head.repo could be null, although this isn't documented in the API doc for listing pull requests:

https://developer.github.com/v3/pulls/#list-pull-requests

This causes github-api to throw an exception:

java.util.NoSuchElementException: None.get

Here's how to recreate the bug with a JSON payload in a file.

import org.json4s.JArray
import org.json4s.jackson.JsonMethods.parse
import codecheck.github.models.PullRequest

val json = scala.io.Source.fromFile("data/prs.json").getLines.mkString
parse(json).asInstanceOf[JArray].arr.map(PullRequest(_)).map(_.head.repo.name)

Pull requests can have their forks deleted:

https://stackoverflow.com/questions/36071272/fix-unknown-repository-of-an-opened-pr-after-deleted-the-fork
isaacs/github#168

This means the head.repo could be null, although this isn't documented
in the API doc for listing pull requests:

https://developer.github.com/v3/pulls/#list-pull-requests

This causes github-api to throw an exception:

java.util.NoSuchElementException: None.get

Here's how to recreate the bug with a JSON payload in a file.

import org.json4s.JArray
import org.json4s.jackson.JsonMethods.parse
import codecheck.github.models.PullRequest

val json = scala.io.Source.fromFile("data/prs.json").getLines.mkString
parse(json).asInstanceOf[JArray].arr.map(PullRequest(_)).map(_.head.repo.name)
@ashawley ashawley force-pushed the fix-null-pr-head-repo branch from 91854f1 to 92fa67a Compare February 18, 2018 19:12
@ashawley
Copy link
Contributor Author

Here is an example of a null repo:

[
  {
    "url": "https://api.github.com/repos/octocat/Hello-World/pulls/1347",
    "id": 1,
    ...
    "head": {
      "label": "new-topic",
      "ref": "new-topic",
      "sha": "e245d1f90f74d67be6635121572c7f83d130c822",
      "user": {
        "login": "octocat",
	...
      },
      "repo": null
    },
    "base": {
      "label": "master",
      "ref": "master",
      "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e",
      "user": {
        "login": "octocat",
	...
      },
      "repo": {
        "id": 1296269,
        "owner": {
          "login": "octocat",
	  ...
	},
      }
    }
    ...
  },
  ...
]

@shunjikonishi shunjikonishi merged commit 6aaaa19 into code-check:master Jul 15, 2019
@ashawley ashawley deleted the fix-null-pr-head-repo branch July 15, 2019 23:45
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.

2 participants