swift icon indicating copy to clipboard operation
swift copied to clipboard

Inline comments are not working

Open yigitcanyurtsever opened this issue 4 years ago • 7 comments

Hello,

I was testing out the SwiftLint plugin with Danger Swift for our PRs. I created a sample PR with 3 new files with some violations in each of them. Danger was able to add only 1 inline comment and the rest was displayed in general results comment. Here's how it looks:

Screen Shot 2019-12-10 at 4 00 04 PM

Some details:

  • Only 1 comment was added as inline. Even if I push another commit, another (random?) comment gets posted as inline and the rest appears under general comment again.
  • All 3 files were added with this PR/commit. So, all the lines were part of my diff.
  • Upon checking the debug output, I found out that all requests except for the first one was getting a validation error with description""pull_request_review_id must be pending" from Github.

I'm attaching the full debug output from our CI as well. I'm not sure if this is a danger-js issue or a danger-swift one. Let me know if I can provide more details.

2019-12-10T23:46:22.569Z danger:process_runner Debug mode on for Danger v9.1.5
2019-12-10T23:46:22.572Z danger:process_runner Starting sub-process run
2019-12-10T23:46:22.575Z danger:GitHub::Checks Not using the checks API for GitHub
2019-12-10T23:46:22.576Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363 { 'Content-Type': 'application/json',
  Accept: 'application/vnd.github.v3.diff',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:22.871Z danger:GitHubAPI getPullRequestCommits:: Sending pull request commit request for first page
2019-12-10T23:46:22.871Z danger:GitHubAPI getPullRequestCommits:: Request url generated "repos/zeplin/[REDACTED]/pulls/1363/commits"
2019-12-10T23:46:22.871Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/commits { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:23.073Z danger:GitHubAPI getNextPageFromLinkHeader:: Given response does not contain link header for pagination
2019-12-10T23:46:23.077Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363 { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:23.349Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/issues/1363 { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:23.580Z danger:GitHubAPI getPullRequestCommits:: Sending pull request commit request for first page
2019-12-10T23:46:23.580Z danger:GitHubAPI getPullRequestCommits:: Request url generated "repos/zeplin/[REDACTED]/pulls/1363/commits"
2019-12-10T23:46:23.580Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/commits { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:23.814Z danger:GitHubAPI getNextPageFromLinkHeader:: Given response does not contain link header for pagination
2019-12-10T23:46:23.815Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/reviews { 'Content-Type': 'application/json',
  Accept: 'application/vnd.github.v3+json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:23.975Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/requested_reviewers { 'Content-Type': 'application/json',
  Accept: 'application/vnd.github.v3+json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:24.145Z danger:process_runner { dangerJSONDSL:
   { git:
      { modified_files: [Array],
        created_files: [Array],
        deleted_files: [],
        commits: [Array] },
     github:
      { issue: [Object],
        pr: [Object],
        commits: [Array],
        reviews: [],
        requested_reviewers: [Object],
        thisPR: [Object] },
     settings: { github: [Object], cliArgs: [Object] } } }
2019-12-10T23:46:24.145Z danger:process_runner Preparing to run: danger-swift
2019-12-10T23:46:24.145Z danger:runDangerSubprocess Running sub-process: danger-swift - 
2019-12-10T23:46:24.152Z danger:runDangerSubprocess Started passing in STDIN via the URL: danger://dsl//var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/danger-dsl.json
2019-12-10T23:46:24.152Z danger:runDangerSubprocess Passed DSL in via STDIN
Ran with: /var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/_tmp_dangerfile.swift /var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/danger-dsl.json /var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/danger-response.json
Decoding the DSL into Swift types
Setting up to dump results
Sending results back to Danger
2019-12-10T23:46:31.234Z danger:runDangerSubprocess Got JSON URL from STDOUT, results are at: 
danger-results://var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/danger-response.json
Got URL for JSON: /var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/danger-dsl.json
Created a temporary file for the Dangerfile DSL at: /var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/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/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/_tmp_dangerfile.swift /var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/danger-dsl.json /var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/danger-response.json
Completed evaluation
Saving and storing the results at /var/folders/6q/wgy6jtp12w5gzgm9lzcglpqw0000gn/T/danger-response.json
2019-12-10T23:46:31.237Z danger:runDangerSubprocess child process exited with code 0
2019-12-10T23:46:31.237Z danger:jsonToDSL Creating pr DSL from JSON
2019-12-10T23:46:31.286Z danger:GitHubGit Got no GH API, had to make it
2019-12-10T23:46:31.286Z danger:GitHubGit Setting up git DSL with:  { repo: 'zeplin/[REDACTED]',
  baseSHA: '125d4e5a43c26d2f7e24a96087dbeba2f956f013',
  headSHA: 'e8293f66c0d99c50991f296dda52437179b0df6d',
  getFileContents: [Function],
  getFullDiff: [Function] }
2019-12-10T23:46:31.287Z danger:executor Got results back: { messages: [],
  markdowns: [],
  meta:
   { runtimeHref: 'https://danger.systems/swift',
     runtimeName: 'Danger Swift' },
  fails: [],
  warnings:
   [ { message: 'Add a changelog entry.' },
     { message: 'Add reviewers.' },
     { message:
        'Limit vertical whitespace to a single empty line. Currently 3. (`vertical_whitespace`)',
       file: 'Zeplin/Models/AnotherTestClass.swift',
       line: 17 },
     { message:
        'Limit vertical whitespace to a single empty line. Currently 3. (`vertical_whitespace`)',
       file: 'Zeplin/Models/TestClass.swift',
       line: 16 },
     { message:
        'Limit vertical whitespace to a single empty line. Currently 3. (`vertical_whitespace`)',
       file: 'Zeplin/Models/TestClass.swift',
       line: 20 },
     { message:
        'Limit vertical whitespace to a single empty line. Currently 3. (`vertical_whitespace`)',
       file: 'Zeplin/Models/TestClass.swift',
       line: 25 },
     { message:
        'Limit vertical whitespace to a single empty line. Currently 3. (`vertical_whitespace`)',
       file: 'Zeplin/Models/TestClass.swift',
       line: 29 },
     { message:
        'Limit vertical whitespace to a single empty line. Currently 3. (`vertical_whitespace`)',
       file: 'Zeplin/Models/ThirdTestClass.swift',
       line: 17 } ] }
2019-12-10T23:46:31.288Z danger:executor Evaluator settings { stdoutOnly: undefined,
  verbose: undefined,
  jsonOnly: false,
  dangerID: 'Danger',
  passURLForDSL: true,
  disableGitHubChecksSupport: true,
  failOnErrors: undefined }
2019-12-10T23:46:31.288Z danger:executor Posting to platform: { messages: [],
  markdowns: [],
  meta:
   { runtimeHref: 'https://danger.systems/swift',
     runtimeName: 'Danger Swift' },
  fails: [],
  warnings:
   [ { message: 'Add a changelog entry.' },
     { message: 'Add reviewers.' },
     { message:
        'Limit vertical whitespace to a single empty line. Currently 3. (`vertical_whitespace`)',
       file: 'Zeplin/Models/AnotherTestClass.swift',
       line: 17 },
     { message:
        'Limit vertical whitespace to a single empty line. Currently 3. (`vertical_whitespace`)',
       file: 'Zeplin/Models/TestClass.swift',
       line: 16 },
     { message:
        'Limit vertical whitespace to a single empty line. Currently 3. (`vertical_whitespace`)',
       file: 'Zeplin/Models/TestClass.swift',
       line: 20 },
     { message:
        'Limit vertical whitespace to a single empty line. Currently 3. (`vertical_whitespace`)',
       file: 'Zeplin/Models/TestClass.swift',
       line: 25 },
     { message:
        'Limit vertical whitespace to a single empty line. Currently 3. (`vertical_whitespace`)',
       file: 'Zeplin/Models/TestClass.swift',
       line: 29 },
     { message:
        'Limit vertical whitespace to a single empty line. Currently 3. (`vertical_whitespace`)',
       file: 'Zeplin/Models/ThirdTestClass.swift',
       line: 17 } ] }
Found only warnings, not failing the build.
2019-12-10T23:46:31.289Z danger:GitHubAPI Sending:  https://api.github.com/user { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:31.414Z danger:GitHubAPI getPullRequestCommits:: Sending pull request commit request for first page
2019-12-10T23:46:31.414Z danger:GitHubAPI getPullRequestCommits:: Request url generated "repos/zeplin/[REDACTED]/pulls/1363/comments"
2019-12-10T23:46:31.414Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/comments { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:32.617Z danger:GitHubAPI getNextPageFromLinkHeader:: Given response does not contain link header for pagination
2019-12-10T23:46:32.617Z danger:GitHub::Issue Creating inline comment. Commit: e8293f66c0d99c50991f296dda52437179b0df6d
2019-12-10T23:46:32.618Z danger:GitHub::Issue Finding position for inline comment.Zeplin/Models/AnotherTestClass.swift#17
2019-12-10T23:46:32.618Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363 { 'Content-Type': 'application/json',
  Accept: 'application/vnd.github.v3.diff',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:32.619Z danger:GitHub::Issue Creating inline comment. Commit: e8293f66c0d99c50991f296dda52437179b0df6d
2019-12-10T23:46:32.619Z danger:GitHub::Issue Finding position for inline comment.Zeplin/Models/TestClass.swift#16
2019-12-10T23:46:32.619Z danger:GitHub::Issue Creating inline comment. Commit: e8293f66c0d99c50991f296dda52437179b0df6d
2019-12-10T23:46:32.619Z danger:GitHub::Issue Finding position for inline comment.Zeplin/Models/TestClass.swift#20
2019-12-10T23:46:32.620Z danger:GitHub::Issue Creating inline comment. Commit: e8293f66c0d99c50991f296dda52437179b0df6d
2019-12-10T23:46:32.620Z danger:GitHub::Issue Finding position for inline comment.Zeplin/Models/TestClass.swift#25
2019-12-10T23:46:32.620Z danger:GitHub::Issue Creating inline comment. Commit: e8293f66c0d99c50991f296dda52437179b0df6d
2019-12-10T23:46:32.620Z danger:GitHub::Issue Finding position for inline comment.Zeplin/Models/TestClass.swift#29
2019-12-10T23:46:32.620Z danger:GitHub::Issue Creating inline comment. Commit: e8293f66c0d99c50991f296dda52437179b0df6d
2019-12-10T23:46:32.620Z danger:GitHub::Issue Finding position for inline comment.Zeplin/Models/ThirdTestClass.swift#17
2019-12-10T23:46:32.836Z danger:GitHub::Issue Diff found for inline comment, now getting a position.Zeplin/Models/AnotherTestClass.swift#17. Diff: {"chunks":[{"content":"@@ -0,0 +1,22 @@","changes":[{"type":"add","add":true,"ln":1,"content":"+//"},{"type":"add","add":true,"ln":2,"content":"+//  AnotherTestClass.swift"},{"type":"add","add":true,"ln":3,"content":"+//  Zeplin"},{"type":"add","add":true,"ln":4,"content":"+//"},{"type":"add","add":true,"ln":5,"content":"+//  Created by Yigitcan Yurtsever on 12/10/19."},{"type":"add","add":true,"ln":6,"content":"+//  Copyright © 2019 Zeplin, Inc. All rights reserved."},{"type":"add","add":true,"ln":7,"content":"+//"},{"type":"add","add":true,"ln":8,"content":"+"},{"type":"add","add":true,"ln":9,"content":"+import Foundation"},{"type":"add","add":true,"ln":10,"content":"+"},{"type":"add","add":true,"ln":11,"content":"+class AnotherTestClass {"},{"type":"add","add":true,"ln":12,"content":"+"},{"type":"add","add":true,"ln":13,"content":"+    // MARK: Properties"},{"type":"add","add":true,"ln":14,"content":"+    var someProperty = 3"},{"type":"add","add":true,"ln":15,"content":"+"},{"type":"add","add":true,"ln":16,"content":"+"},{"type":"add","add":true,"ln":17,"content":"+"},{"type":"add","add":true,"ln":18,"content":"+    func increment() {"},{"type":"add","add":true,"ln":19,"content":"+            someProperty += 1"},{"type":"add","add":true,"ln":20,"content":"+    }"},{"type":"add","add":true,"ln":21,"content":"+"},{"type":"add","add":true,"ln":22,"content":"+}"}],"oldStart":0,"oldLines":0,"newStart":1,"newLines":22}]}
2019-12-10T23:46:32.836Z danger:GitHub::Issue Position found for inline comment: 17.Zeplin/Models/AnotherTestClass.swift#17
2019-12-10T23:46:32.836Z danger:GitHub::Issue Diff found for inline comment, now getting a position.Zeplin/Models/TestClass.swift#16. Diff: {"chunks":[{"content":"@@ -0,0 +1,30 @@","changes":[{"type":"add","add":true,"ln":1,"content":"+//"},{"type":"add","add":true,"ln":2,"content":"+//  TestClass.swift"},{"type":"add","add":true,"ln":3,"content":"+//  Zeplin"},{"type":"add","add":true,"ln":4,"content":"+//"},{"type":"add","add":true,"ln":5,"content":"+//  Created by Yigitcan Yurtsever on 12/6/19."},{"type":"add","add":true,"ln":6,"content":"+//  Copyright © 2019 Zeplin, Inc. All rights reserved."},{"type":"add","add":true,"ln":7,"content":"+//"},{"type":"add","add":true,"ln":8,"content":"+"},{"type":"add","add":true,"ln":9,"content":"+import Foundation"},{"type":"add","add":true,"ln":10,"content":"+"},{"type":"add","add":true,"ln":11,"content":"+class TestClass {"},{"type":"add","add":true,"ln":12,"content":"+"},{"type":"add","add":true,"ln":13,"content":"+    // MARK: Properties"},{"type":"add","add":true,"ln":14,"content":"+"},{"type":"add","add":true,"ln":15,"content":"+"},{"type":"add","add":true,"ln":16,"content":"+"},{"type":"add","add":true,"ln":17,"content":"+    var someProperty = 3"},{"type":"add","add":true,"ln":18,"content":"+"},{"type":"add","add":true,"ln":19,"content":"+"},{"type":"add","add":true,"ln":20,"content":"+"},{"type":"add","add":true,"ln":21,"content":"+    func increment() {"},{"type":"add","add":true,"ln":22,"content":"+        someProperty += 1"},{"type":"add","add":true,"ln":23,"content":"+"},{"type":"add","add":true,"ln":24,"content":"+"},{"type":"add","add":true,"ln":25,"content":"+"},{"type":"add","add":true,"ln":26,"content":"+    }"},{"type":"add","add":true,"ln":27,"content":"+"},{"type":"add","add":true,"ln":28,"content":"+"},{"type":"add","add":true,"ln":29,"content":"+"},{"type":"add","add":true,"ln":30,"content":"+}"}],"oldStart":0,"oldLines":0,"newStart":1,"newLines":30}]}
2019-12-10T23:46:32.836Z danger:GitHub::Issue Position found for inline comment: 16.Zeplin/Models/TestClass.swift#16
2019-12-10T23:46:32.836Z danger:GitHub::Issue Diff found for inline comment, now getting a position.Zeplin/Models/TestClass.swift#20. Diff: {"chunks":[{"content":"@@ -0,0 +1,30 @@","changes":[{"type":"add","add":true,"ln":1,"content":"+//"},{"type":"add","add":true,"ln":2,"content":"+//  TestClass.swift"},{"type":"add","add":true,"ln":3,"content":"+//  Zeplin"},{"type":"add","add":true,"ln":4,"content":"+//"},{"type":"add","add":true,"ln":5,"content":"+//  Created by Yigitcan Yurtsever on 12/6/19."},{"type":"add","add":true,"ln":6,"content":"+//  Copyright © 2019 Zeplin, Inc. All rights reserved."},{"type":"add","add":true,"ln":7,"content":"+//"},{"type":"add","add":true,"ln":8,"content":"+"},{"type":"add","add":true,"ln":9,"content":"+import Foundation"},{"type":"add","add":true,"ln":10,"content":"+"},{"type":"add","add":true,"ln":11,"content":"+class TestClass {"},{"type":"add","add":true,"ln":12,"content":"+"},{"type":"add","add":true,"ln":13,"content":"+    // MARK: Properties"},{"type":"add","add":true,"ln":14,"content":"+"},{"type":"add","add":true,"ln":15,"content":"+"},{"type":"add","add":true,"ln":16,"content":"+"},{"type":"add","add":true,"ln":17,"content":"+    var someProperty = 3"},{"type":"add","add":true,"ln":18,"content":"+"},{"type":"add","add":true,"ln":19,"content":"+"},{"type":"add","add":true,"ln":20,"content":"+"},{"type":"add","add":true,"ln":21,"content":"+    func increment() {"},{"type":"add","add":true,"ln":22,"content":"+        someProperty += 1"},{"type":"add","add":true,"ln":23,"content":"+"},{"type":"add","add":true,"ln":24,"content":"+"},{"type":"add","add":true,"ln":25,"content":"+"},{"type":"add","add":true,"ln":26,"content":"+    }"},{"type":"add","add":true,"ln":27,"content":"+"},{"type":"add","add":true,"ln":28,"content":"+"},{"type":"add","add":true,"ln":29,"content":"+"},{"type":"add","add":true,"ln":30,"content":"+}"}],"oldStart":0,"oldLines":0,"newStart":1,"newLines":30}]}
2019-12-10T23:46:32.836Z danger:GitHub::Issue Position found for inline comment: 20.Zeplin/Models/TestClass.swift#20
2019-12-10T23:46:32.836Z danger:GitHub::Issue Diff found for inline comment, now getting a position.Zeplin/Models/TestClass.swift#25. Diff: {"chunks":[{"content":"@@ -0,0 +1,30 @@","changes":[{"type":"add","add":true,"ln":1,"content":"+//"},{"type":"add","add":true,"ln":2,"content":"+//  TestClass.swift"},{"type":"add","add":true,"ln":3,"content":"+//  Zeplin"},{"type":"add","add":true,"ln":4,"content":"+//"},{"type":"add","add":true,"ln":5,"content":"+//  Created by Yigitcan Yurtsever on 12/6/19."},{"type":"add","add":true,"ln":6,"content":"+//  Copyright © 2019 Zeplin, Inc. All rights reserved."},{"type":"add","add":true,"ln":7,"content":"+//"},{"type":"add","add":true,"ln":8,"content":"+"},{"type":"add","add":true,"ln":9,"content":"+import Foundation"},{"type":"add","add":true,"ln":10,"content":"+"},{"type":"add","add":true,"ln":11,"content":"+class TestClass {"},{"type":"add","add":true,"ln":12,"content":"+"},{"type":"add","add":true,"ln":13,"content":"+    // MARK: Properties"},{"type":"add","add":true,"ln":14,"content":"+"},{"type":"add","add":true,"ln":15,"content":"+"},{"type":"add","add":true,"ln":16,"content":"+"},{"type":"add","add":true,"ln":17,"content":"+    var someProperty = 3"},{"type":"add","add":true,"ln":18,"content":"+"},{"type":"add","add":true,"ln":19,"content":"+"},{"type":"add","add":true,"ln":20,"content":"+"},{"type":"add","add":true,"ln":21,"content":"+    func increment() {"},{"type":"add","add":true,"ln":22,"content":"+        someProperty += 1"},{"type":"add","add":true,"ln":23,"content":"+"},{"type":"add","add":true,"ln":24,"content":"+"},{"type":"add","add":true,"ln":25,"content":"+"},{"type":"add","add":true,"ln":26,"content":"+    }"},{"type":"add","add":true,"ln":27,"content":"+"},{"type":"add","add":true,"ln":28,"content":"+"},{"type":"add","add":true,"ln":29,"content":"+"},{"type":"add","add":true,"ln":30,"content":"+}"}],"oldStart":0,"oldLines":0,"newStart":1,"newLines":30}]}
2019-12-10T23:46:32.836Z danger:GitHub::Issue Position found for inline comment: 25.Zeplin/Models/TestClass.swift#25
2019-12-10T23:46:32.837Z danger:GitHub::Issue Diff found for inline comment, now getting a position.Zeplin/Models/TestClass.swift#29. Diff: {"chunks":[{"content":"@@ -0,0 +1,30 @@","changes":[{"type":"add","add":true,"ln":1,"content":"+//"},{"type":"add","add":true,"ln":2,"content":"+//  TestClass.swift"},{"type":"add","add":true,"ln":3,"content":"+//  Zeplin"},{"type":"add","add":true,"ln":4,"content":"+//"},{"type":"add","add":true,"ln":5,"content":"+//  Created by Yigitcan Yurtsever on 12/6/19."},{"type":"add","add":true,"ln":6,"content":"+//  Copyright © 2019 Zeplin, Inc. All rights reserved."},{"type":"add","add":true,"ln":7,"content":"+//"},{"type":"add","add":true,"ln":8,"content":"+"},{"type":"add","add":true,"ln":9,"content":"+import Foundation"},{"type":"add","add":true,"ln":10,"content":"+"},{"type":"add","add":true,"ln":11,"content":"+class TestClass {"},{"type":"add","add":true,"ln":12,"content":"+"},{"type":"add","add":true,"ln":13,"content":"+    // MARK: Properties"},{"type":"add","add":true,"ln":14,"content":"+"},{"type":"add","add":true,"ln":15,"content":"+"},{"type":"add","add":true,"ln":16,"content":"+"},{"type":"add","add":true,"ln":17,"content":"+    var someProperty = 3"},{"type":"add","add":true,"ln":18,"content":"+"},{"type":"add","add":true,"ln":19,"content":"+"},{"type":"add","add":true,"ln":20,"content":"+"},{"type":"add","add":true,"ln":21,"content":"+    func increment() {"},{"type":"add","add":true,"ln":22,"content":"+        someProperty += 1"},{"type":"add","add":true,"ln":23,"content":"+"},{"type":"add","add":true,"ln":24,"content":"+"},{"type":"add","add":true,"ln":25,"content":"+"},{"type":"add","add":true,"ln":26,"content":"+    }"},{"type":"add","add":true,"ln":27,"content":"+"},{"type":"add","add":true,"ln":28,"content":"+"},{"type":"add","add":true,"ln":29,"content":"+"},{"type":"add","add":true,"ln":30,"content":"+}"}],"oldStart":0,"oldLines":0,"newStart":1,"newLines":30}]}
2019-12-10T23:46:32.837Z danger:GitHub::Issue Position found for inline comment: 29.Zeplin/Models/TestClass.swift#29
2019-12-10T23:46:32.837Z danger:GitHub::Issue Diff found for inline comment, now getting a position.Zeplin/Models/ThirdTestClass.swift#17. Diff: {"chunks":[{"content":"@@ -0,0 +1,22 @@","changes":[{"type":"add","add":true,"ln":1,"content":"+//"},{"type":"add","add":true,"ln":2,"content":"+//  ThirdTestClass.swift"},{"type":"add","add":true,"ln":3,"content":"+//  Zeplin"},{"type":"add","add":true,"ln":4,"content":"+//"},{"type":"add","add":true,"ln":5,"content":"+//  Created by Yigitcan Yurtsever on 12/10/19."},{"type":"add","add":true,"ln":6,"content":"+//  Copyright © 2019 Zeplin, Inc. All rights reserved."},{"type":"add","add":true,"ln":7,"content":"+//"},{"type":"add","add":true,"ln":8,"content":"+"},{"type":"add","add":true,"ln":9,"content":"+import Foundation"},{"type":"add","add":true,"ln":10,"content":"+"},{"type":"add","add":true,"ln":11,"content":"+class ThirdTestClass {"},{"type":"add","add":true,"ln":12,"content":"+"},{"type":"add","add":true,"ln":13,"content":"+    // MARK: Properties"},{"type":"add","add":true,"ln":14,"content":"+    var someProperty = 3"},{"type":"add","add":true,"ln":15,"content":"+"},{"type":"add","add":true,"ln":16,"content":"+"},{"type":"add","add":true,"ln":17,"content":"+"},{"type":"add","add":true,"ln":18,"content":"+    func increment() {"},{"type":"add","add":true,"ln":19,"content":"+            someProperty += 1"},{"type":"add","add":true,"ln":20,"content":"+    }"},{"type":"add","add":true,"ln":21,"content":"+"},{"type":"add","add":true,"ln":22,"content":"+}"}],"oldStart":0,"oldLines":0,"newStart":1,"newLines":22}]}
2019-12-10T23:46:32.837Z danger:GitHub::Issue Position found for inline comment: 17.Zeplin/Models/ThirdTestClass.swift#17
2019-12-10T23:46:32.837Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/comments { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:32.839Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/comments { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:32.840Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/comments { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:32.841Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/comments { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:32.842Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/comments { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:32.842Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/comments { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
Request failed [422]: https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/comments
Response: {
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "PullRequestReviewComment",
      "code": "custom",
      "field": "pull_request_review_id",
      "message": "pull_request_review_id must be pending"
    }
  ],
  "documentation_url": "https://developer.github.com/v3/pulls/comments/#create-a-comment"
}
Request failed [422]: https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/comments
Response: {
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "PullRequestReviewComment",
      "code": "custom",
      "field": "pull_request_review_id",
      "message": "pull_request_review_id must be pending"
    }
  ],
  "documentation_url": "https://developer.github.com/v3/pulls/comments/#create-a-comment"
}
Request failed [422]: https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/comments
Response: {
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "PullRequestReviewComment",
      "code": "custom",
      "field": "pull_request_review_id",
      "message": "pull_request_review_id must be pending"
    }
  ],
  "documentation_url": "https://developer.github.com/v3/pulls/comments/#create-a-comment"
}
Request failed [422]: https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/comments
Response: {
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "PullRequestReviewComment",
      "code": "custom",
      "field": "pull_request_review_id",
      "message": "pull_request_review_id must be pending"
    }
  ],
  "documentation_url": "https://developer.github.com/v3/pulls/comments/#create-a-comment"
}
Request failed [422]: https://api.github.com/repos/zeplin/[REDACTED]/pulls/1363/comments
Response: {
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "PullRequestReviewComment",
      "code": "custom",
      "field": "pull_request_review_id",
      "message": "pull_request_review_id must be pending"
    }
  ],
  "documentation_url": "https://developer.github.com/v3/pulls/comments/#create-a-comment"
}
2019-12-10T23:46:33.947Z danger:GitHubAPI Sending:  https://api.github.com/user { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:34.108Z danger:GitHubAPI getPullRequestCommits:: Sending pull request commit request for first page
2019-12-10T23:46:34.108Z danger:GitHubAPI getPullRequestCommits:: Request url generated "repos/zeplin/[REDACTED]/issues/1363/comments"
2019-12-10T23:46:34.108Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/issues/1363/comments { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
2019-12-10T23:46:34.279Z danger:GitHubAPI getNextPageFromLinkHeader:: Given response does not contain link header for pagination
2019-12-10T23:46:34.279Z danger:GitHubAPI User ID: 12931937
2019-12-10T23:46:34.279Z danger:GitHubAPI Looking at 0 comments for DangerID: danger-id-Danger;
2019-12-10T23:46:34.279Z danger:GitHub::Issue Creating new comment
2019-12-10T23:46:34.279Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/issues/1363/comments { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }
Feedback: https://github.com/zeplin/[REDACTED]/pull/1363#issuecomment-564311458
2019-12-10T23:46:34.996Z danger:GitHubAPI Sending:  https://api.github.com/repos/zeplin/[REDACTED]/statuses/e8293f66c0d99c50991f296dda52437179b0df6d { 'Content-Type': 'application/json',
  Authorization: 'token [REDACTED]' }

yigitcanyurtsever avatar Dec 11 '19 00:12 yigitcanyurtsever

Were those comments in the diff? GitHub's API doesn't let you make comments on any random files in the repo - they have to live on the diff in the PR.

orta avatar Dec 11 '19 17:12 orta

Thanks for looking into it @orta 🙌

Yes, all three files were created/added on the same commit and were part of the diff.

When I was debugging the issue, I also tried adding comments that were not part of the diff. When they are not part of the diff, Github returns a "invalid position" validation error. The response looks like this:

Response: {
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "PullRequestReviewComment",
      "code": "invalid",
      "field": "position"
    }
  ],
  "documentation_url": "https://developer.github.com/v3/pulls/comments/#create-a-comment"
}

These ones on the other hand, returns a "pull_request_review_id must be pending". Here's how it looks:

Response: {
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "PullRequestReviewComment",
      "code": "custom",
      "field": "pull_request_review_id",
      "message": "pull_request_review_id must be pending"
    }
  ],
  "documentation_url": "https://developer.github.com/v3/pulls/comments/#create-a-comment"
}

I couldn't find any documentation for these errors on Github. My only guess is that, when danger is trying to make inline comments, it sends out the review immediately after making the first comment. The rest of the comments receive a validation error because the review was already sent and it's not in "pending" state anymore. Although, If this was the case, it would be a really common issue that other people also run into. So, I'm thinking we are doing some other things that trigger this early review sending for us.

yigitcanyurtsever avatar Dec 11 '19 21:12 yigitcanyurtsever

I'm also running into a similar issue, with danger-js. I get these warnings:

Found only warnings, not failing the build.
Request failed [422]: https://api.github.com/repos/next-insurance/skyscraper/pulls/17831/comments
Response: {
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "PullRequestReviewComment",
      "code": "custom",
      "field": "pull_request_review_id",
      "message": "pull_request_review_id must be pending"
    }
  ],
  "documentation_url": "https://developer.github.com/v3/pulls/comments/#create-a-comment"
}
Feedback: https://github.com/next-insurance/skyscraper/pull/17831#issuecomment-664449196

My setup - I have a jenkins job that polls my private repository (it's a commercial company), and runs Danger, with a github-bot. I pass the token via DANGER_GITHUB_API_TOKEN. I've tried setting the bot's id via PERIL_BOT_USER_ID (tried to follow these instructions by @orta ) - it didn't make a difference.

@yigitcanyurtsever 's theory sounds logical to me. I was hoping maybe this issue was solved by now... I'm still investigating mine.

pinkasey avatar Jul 27 '20 15:07 pinkasey

I've turned DEBUG on (set the environment variable DEBUG to *), to get more information, and it seems like:

  1. theory is correct - Danger invokes the same API twice, and fails the second time
  2. me setting PERIL_BOT_USER_ID to the bot's id did nothing - see danger:GitHubAPI User ID: NaN So I'm suspecting this has to do with getUserID returning NaN, and that it does because I'm using a bot instead of a regular user.

Here's the log from my Jenkins run of Danger-JS:

18:29:47  2020-07-27T15:29:47.591Z danger:GitHub::Issue Position found for inline comment: blah blah blah...
18:29:47  2020-07-27T15:29:47.592Z danger:GitHubAPI Sending:  https://api.github.com/repos/next-insurance/skyscraper/pulls/17831/comments {
18:29:47    'Content-Type': 'application/json',
18:29:47    Authorization: 'token ****'
18:29:47  }
18:29:47  2020-07-27T15:29:47.593Z danger:GitHubAPI Sending:  https://api.github.com/repos/next-insurance/skyscraper/pulls/17831/comments {
18:29:47    'Content-Type': 'application/json',
18:29:47    Authorization: 'token ****'
18:29:47  }
18:29:48  Request failed [422]: https://api.github.com/repos/next-insurance/skyscraper/pulls/17831/comments
18:29:48  Response: {
18:29:48    "message": "Validation Failed",
18:29:48    "errors": [
18:29:48      {
18:29:48        "resource": "PullRequestReviewComment",
18:29:48        "code": "custom",
18:29:48        "field": "pull_request_review_id",
18:29:48        "message": "pull_request_review_id must be pending"
18:29:48      }
18:29:48    ],
18:29:48    "documentation_url": "https://developer.github.com/v3/pulls/comments/#create-a-comment"
18:29:48  }
18:29:48  2020-07-27T15:29:48.474Z danger:GitHubAPI getPullRequestCommits:: Sending pull request commit request for first page
18:29:48  2020-07-27T15:29:48.474Z danger:GitHubAPI getPullRequestCommits:: Request url generated "repos/next-insurance/skyscraper/issues/17831/comments"
18:29:48  2020-07-27T15:29:48.474Z danger:GitHubAPI Sending:  https://api.github.com/repos/next-insurance/skyscraper/issues/17831/comments {
18:29:48    'Content-Type': 'application/json',
18:29:48    Authorization: 'token ****'
18:29:48  }
18:29:48  2020-07-27T15:29:48.719Z danger:GitHubAPI getNextPageFromLinkHeader:: Given response does not contain link header for pagination
18:29:48  2020-07-27T15:29:48.719Z danger:GitHubAPI User ID: NaN
18:29:48  2020-07-27T15:29:48.719Z danger:GitHubAPI Looking at 1 comments for DangerID: danger-id-Danger;
18:29:48  2020-07-27T15:29:48.719Z danger:GitHub::Issue Creating new comment
18:29:48  2020-07-27T15:29:48.719Z danger:GitHubAPI Sending:  https://api.github.com/repos/next-insurance/skyscraper/issues/17831/comments {
18:29:48    'Content-Type': 'application/json',
18:29:48    Authorization: 'token ****'
18:29:48  }
18:29:49  Feedback: https://github.com/next-insurance/skyscraper/pull/17831#issuecomment-664466380
18:29:49  2020-07-27T15:29:49.551Z danger:GitHubAPI Sending:  https://api.github.com/repos/next-insurance/skyscraper/statuses/1e08eb352b498dee932c00fce380c74470626a1b {
18:29:49    'Content-Type': 'application/json',
18:29:49    Authorization: 'token ****'
18:29:49  }

P.S: Hope it's OK I'm posting here, even though I'm using danger-js and not swift. I came here when searching for the error message. Plus, I think if we solve this, the solution may apply to swift as well.

pinkasey avatar Jul 27 '20 15:07 pinkasey

I've fixed the PERIL_BOT_USER_ID, but it didn't solve the issue. I'm still getting these errors from the second inline-comment and on.

At least fixing PERIL_BOT_USER_ID fixed another issue - now Danger updates its summary comment, instead of creating a new one every run.

How I've fixed my PERIL_BOT_USER_ID (for anyone who comes across this) When I was looking for user.id to put in PERIL_BOT_USER_ID, I was using GitHub GraphQL API, which uses a different API than Danger-JS. So I didn't know what field to look for. It's not user.id - first, there's no user in this API version, there's author. second - author.id is not numeric - it's a GUID. Eventually I realized the field I was looking for was databaseId, which is numeric.

pinkasey avatar Jul 27 '20 16:07 pinkasey

Hi, how about this issue?

I'm still having this issue

codingtive avatar Oct 25 '21 03:10 codingtive

It opens a review for the first review comment you add. You have to await that call before adding more comments. Otherwise, you end up with a race condition where it tries to add more comments while the review is still getting set up.

dprothero avatar Mar 18 '22 20:03 dprothero