blahgeek / emacs-pr-review

GNU General Public License v3.0
43 stars 2 forks source link

Error when submitting review #3

Closed mz-pdm closed 2 years ago

mz-pdm commented 2 years ago

When I try to submit a review, e.g. using COMMENT action, it fails with: pr-review--execute-graphql: Error while making graphql request add-review: nil: Variable $input of type AddPullRequestReviewInput! was provided invalid value for threads.0.startLine (Could not coerce value false to Int), threads.0.startSide (Expected false to be one of: LEFT, RIGHT)

It used to work before but stopped working several works ago. Too bad, emacs-pr-review is cool. :-)

Apparently the problem is that emacs-pr-review attempts to send empty startLine and startSide: (threads ((body . nice!) (path . foo) (line . 1) (side . RIGHT) (startLine) (startSide)))

The following quick hack seems to fix it:

diff --git a/pr-review-action.el b/pr-review-action.el
index a14a68f..d78ba8a 100644
--- a/pr-review-action.el
+++ b/pr-review-action.el
@@ -141,9 +141,11 @@ When a region is active, the review thread is added for multiple lines."
         (message "Cannot add review thread at current point")
       (setq review-thread `((path . ,(cadr line-info))
                             (line . ,(cddr line-info))
-                            (side . ,(car line-info))
-                            (startLine . ,(cddr start-line-info))
-                            (startSide . ,(car start-line-info))))
+                            (side . ,(car line-info))))
+      (when start-line-info
+        (setq review-thread (append start-line-info
+                                    `((startLine . ,(cddr start-line-info))
+                                      (startSide . ,(car start-line-info))))))
       (when (use-region-p)
         (setq region-text (replace-regexp-in-string
                            (rx line-start (any ?+ ?- ?\s)) ""
blahgeek commented 2 years ago

Thanks for your report! It seems to be caused by a server-side change in the github side. I've pushed the fix in a1d35f5633d7181371e795e3f98c900ba5845bb6, please let me know if there's any other problems

mz-pdm commented 2 years ago

Thanks for the fixes, it seems to work.