danger / swift

⚠️ Stop saying "you forgot to …" in code review
https://danger.systems/swift/
MIT License
1.04k stars 136 forks source link

GitHub API dataCorrupted error #425

Open Huddie opened 3 years ago

Huddie commented 3 years ago

Trying to get the comments on a PR.

Code:

let group = DispatchGroup()
group.enter()
_ = danger.github.api.issueComments(
    owner: "foo",
    repository: "bar",
    number: danger.github.issue.number) { (response: Response<[Comment]>) in
    switch response {
    case .success(let comments): 
            // do stuff
    case .failure(let error):
            print("[ERROR]: ", error)
    }
    group.leave()
)
group.wait()

Issues:

  1. I needed to add the DispatchGroup logic otherwise it seemed to end before getting the response back from the Octokit
  2. I get: [ERROR]: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "The given data was not valid JSON.", underlyingError: Optional(Error Domain=NSCocoaErrorDomain Code=3840 "Invalid value around character 1." UserInfo={NSDebugDescription=Invalid value around character 1.})))

Not really sure how to even debug. Any idea why this is happening/how to fix?

f-meloni commented 3 years ago

Sorry for the delay! I totally missed this issue

The issue comment function comes from https://github.com/nerdishbynature/octokit.swift so that is probably a good starting point. The dependency was recently updated https://github.com/danger/swift/pull/417, but to doesn't seem that this change is related to the issue.