swift icon indicating copy to clipboard operation
swift copied to clipboard

GitHub API dataCorrupted error

Open Huddie opened this issue 5 years ago • 1 comments

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?

Huddie avatar Mar 14 '21 00:03 Huddie

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.

f-meloni avatar Apr 03 '21 13:04 f-meloni