danger-js
danger-js copied to clipboard
TypeError: Cannot read property 'full_name' of null on PR with deleted repo
Summary
While trying to set up danger-swift I ran
DEBUG="*" danger-swift pr https://github.com/danger/swift/pull/95
Which gave the following error
Error: TypeError: Cannot read property 'full_name' of null
at Object.utils [as default] (/snapshot/danger-js/distribution/platforms/github/GitHubUtils.js:66:77)
at Object.exports.githubJSONToGitHubDSL (/snapshot/danger-js/distribution/platforms/GitHub.js:127:69)
at Object.<anonymous> (/snapshot/danger-js/distribution/runner/jsonToDSL.js:76:49)
at step (/snapshot/danger-js/distribution/runner/jsonToDSL.js:32:23)
at Object.f [as next] (/snapshot/danger-js/distribution/runner/jsonToDSL.js:13:53)
at __awaiter (/snapshot/danger-js/distribution/runner/jsonToDSL.js:7:71)
at new Promise (<anonymous>)
at __awaiter (/snapshot/danger-js/distribution/runner/jsonToDSL.js:3:12)
at Object.exports.jsonToDSL (/snapshot/danger-js/distribution/runner/jsonToDSL.js:67:53)
at Object.<anonymous> (/snapshot/danger-js/distribution/commands/utils/runDangerSubprocess.js:159:54)
Setup
brew install danger/tap/danger-swift
Dangerfile.swift
import Danger
let danger = Danger()
let editedFiles = danger.git.modifiedFiles + danger.git.createdFiles
message("These files have changed: \(editedFiles.joined())")
Full Debug Output
$ DEBUG="*" danger-swift pr https://github.com/danger/swift/pull/95
Launching Danger Swift pr (v2.0.6)
Finding out where the danger executable is
Running: /usr/local/bin/danger pr --process danger-swift --passURLForDSL https://github.com/danger/swift/pull/95
Starting Danger PR on danger/swift#95
You don't have a DANGER_GITHUB_API_TOKEN set up, this is optional, but TBH, you want to do this
Check out: http://danger.systems/js/guides/the_dangerfile.html#working-on-your-dangerfile
danger:GitHub::Checks Not using the checks API for GitHub +0ms
danger:pr running process separated Danger +0ms
danger:process_runner Debug mode on for Danger v9.1.5 +0ms
danger:process_runner Starting sub-process run +0ms
danger:GitHubAPI Sending: https://api.github.com/repos/danger/swift/pulls/95 { 'Content-Type': 'application/json',
Accept: 'application/vnd.github.v3.diff' } +0ms
danger:GitHubAPI getPullRequestCommits:: Sending pull request commit request for first page +598ms
danger:GitHubAPI getPullRequestCommits:: Request url generated "repos/danger/swift/pulls/95/commits" +0ms
danger:GitHubAPI Sending: https://api.github.com/repos/danger/swift/pulls/95/commits { 'Content-Type': 'application/json' } +0ms
danger:GitHubAPI getNextPageFromLinkHeader:: Given response does not contain link header for pagination +402ms
danger:GitHubAPI Sending: https://api.github.com/repos/danger/swift/pulls/95 { 'Content-Type': 'application/json' } +14ms
danger:GitHubAPI Sending: https://api.github.com/repos/danger/swift/issues/95 { 'Content-Type': 'application/json' } +357ms
danger:GitHubAPI getPullRequestCommits:: Sending pull request commit request for first page +352ms
danger:GitHubAPI getPullRequestCommits:: Request url generated "repos/danger/swift/pulls/95/commits" +0ms
danger:GitHubAPI Sending: https://api.github.com/repos/danger/swift/pulls/95/commits { 'Content-Type': 'application/json' } +0ms
danger:GitHubAPI getNextPageFromLinkHeader:: Given response does not contain link header for pagination +790ms
danger:GitHubAPI Sending: https://api.github.com/repos/danger/swift/pulls/95/reviews { 'Content-Type': 'application/json',
Accept: 'application/vnd.github.v3+json' } +0ms
danger:GitHubAPI Sending: https://api.github.com/repos/danger/swift/pulls/95/requested_reviewers { 'Content-Type': 'application/json',
Accept: 'application/vnd.github.v3+json' } +396ms
danger:process_runner { dangerJSONDSL:
danger:process_runner { git:
danger:process_runner { modified_files: [Array],
danger:process_runner created_files: [Array],
danger:process_runner deleted_files: [],
danger:process_runner commits: [Array] },
danger:process_runner github:
danger:process_runner { issue: [Object],
danger:process_runner pr: [Object],
danger:process_runner commits: [Array],
danger:process_runner reviews: [Array],
danger:process_runner requested_reviewers: [Object],
danger:process_runner thisPR: [Object] },
danger:process_runner settings: { github: [Object], cliArgs: [Object] } } } +3s
danger:process_runner Preparing to run: danger-swift +1ms
danger:runDangerSubprocess Running sub-process: danger-swift - +0ms
danger:runDangerSubprocess Started passing in STDIN via the URL: danger://dsl//var/folders/tw/mbrpz7ds19v8xy5qhqy27zzm0000gq/T/danger-dsl.json +7ms
danger:runDangerSubprocess Passed DSL in via STDIN +0ms
Ran with: /var/folders/tw/mbrpz7ds19v8xy5qhqy27zzm0000gq/T/_tmp_dangerfile.swift /var/folders/tw/mbrpz7ds19v8xy5qhqy27zzm0000gq/T/danger-dsl.json /var/folders/tw/mbrpz7ds19v8xy5qhqy27zzm0000gq/T/danger-response.json
Decoding the DSL into Swift types
ERROR: Failed to parse JSON: valueNotFound(Swift.KeyedDecodingContainer<Danger.GitHub.Repo.CodingKeys>, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "danger", intValue: nil), CodingKeys(stringValue: "github", intValue: nil), CodingKeys(stringValue: "pr", intValue: nil), CodingKeys(stringValue: "head", intValue: nil), CodingKeys(stringValue: "repo", intValue: nil)], debugDescription: "Cannot get keyed decoding container -- found null value instead.", underlyingError: nil))
Got URL for JSON: /var/folders/tw/mbrpz7ds19v8xy5qhqy27zzm0000gq/T/danger-dsl.json
Created a temporary file for the Dangerfile DSL at: /var/folders/tw/mbrpz7ds19v8xy5qhqy27zzm0000gq/T/danger-dsl.json
Running Dangerfile at: Dangerfile.swift
Preparing to compile
Running: /usr/bin/swiftc --driver-mode=swift -L /usr/local/lib/danger -I /usr/local/lib/danger -lDanger /var/folders/tw/mbrpz7ds19v8xy5qhqy27zzm0000gq/T/_tmp_dangerfile.swift /var/folders/tw/mbrpz7ds19v8xy5qhqy27zzm0000gq/T/danger-dsl.json /var/folders/tw/mbrpz7ds19v8xy5qhqy27zzm0000gq/T/danger-response.json
Completed evaluation
ERROR: Dangerfile eval failed at Dangerfile.swift
ERROR: Could not get the results JSON file at /var/folders/tw/mbrpz7ds19v8xy5qhqy27zzm0000gq/T/danger-response.json
danger:runDangerSubprocess child process exited with code 1 +485ms
danger:runDangerSubprocess Handling fail from subprocess +0ms
danger:jsonToDSL Creating pr DSL from JSON +0ms
Error: TypeError: Cannot read property 'full_name' of null
at Object.utils [as default] (/snapshot/danger-js/distribution/platforms/github/GitHubUtils.js:66:77)
at Object.exports.githubJSONToGitHubDSL (/snapshot/danger-js/distribution/platforms/GitHub.js:127:69)
at Object.<anonymous> (/snapshot/danger-js/distribution/runner/jsonToDSL.js:76:49)
at step (/snapshot/danger-js/distribution/runner/jsonToDSL.js:32:23)
at Object.f [as next] (/snapshot/danger-js/distribution/runner/jsonToDSL.js:13:53)
at __awaiter (/snapshot/danger-js/distribution/runner/jsonToDSL.js:7:71)
at new Promise (<anonymous>)
at __awaiter (/snapshot/danger-js/distribution/runner/jsonToDSL.js:3:12)
at Object.exports.jsonToDSL (/snapshot/danger-js/distribution/runner/jsonToDSL.js:67:53)
at Object.<anonymous> (/snapshot/danger-js/distribution/commands/utils/runDangerSubprocess.js:159:54)
This one is quite interesting, I think is more a danger-js bug, but the repo for that PR is null
"repo": null
repo can be null!?
It shouldn't, but if you run danger pr https://github.com/danger/swift/pull/95 --json you get it, also, another interesting thing:
the repo inside "pr" is nil, but not the one inside "base" 🤔
Legit - probably a deleted repo

My gut says Danger JS should bail on purpose with a good UI
So I used that PR (https://github.com/danger/swift/pull/95) since that was the once mentioned in the getting started guide. It was a merged PR so I thought it might be weird but that maybe it could still work.
I tried danger-swift pr https://github.com/danger/swift/pull/275 which is a currently open PR and it seems to work as expected.
Apologies for the confusion.
Totally fine, I'm moving this over to the danger-js repo because we should at least have it error out at that level with a good message. Danger's normally built for active PRs, but danger pr is super useful for working against older PRs. If the PR is totally outside of the normal experience then it's not worth adding nullability for.
Legit - probably a deleted repo
It totally makes sense, didn't think about it