magit / forge

Work with Git forges from the comfort of Magit
GNU General Public License v3.0
1.3k stars 113 forks source link

forge-pull-notifications fails with error `error in process filter: GraphQL Error: ((message . "Parse error on \"(\" (LPAREN) at [3, 17]") (locations ((line . 3) (column . 17))))` #644

Closed Herschenglime closed 6 months ago

Herschenglime commented 6 months ago

Forge seems unable to successfully add a repository to the database and list pull requests. It is also unable to fetch my notifications.

When trying to add a private repository in an organization that I have access to, nothing updates. Trying to list pull requests returns the error "Cannot determine repository".

forge-pull-notifications also fails with the error error in process filter: GraphQL Error: ((message . "Parse error on \"(\" (LPAREN) at [3, 17]") (locations ((line . 3) (column . 17)))) making me wonder if something is wrong with my setup as a whole and not just these repositories.

I have my ghub credentials stored in Secret Service and my auth-sources uses "secrets:Login" to access the password. Making a request directly through ghub (with (ghub-request "GET" "/user")) works fine and returns my user details.

I don't really know what specific aspects of my setup would be causing this, so as such I don't have concrete examples of how to reproduce the error. If there are any extra details you'd like, please let me know.

Thank you for your help!

Backtrace

Cannot determine repository

Debugger entered--Lisp error: (error "Cannot determine repository")
  error("Cannot determine repository")
  (if (or repo global) nil (error "Cannot determine repository"))
  (let* ((repo (or repo (and (not global) (let* ((topic ...) (repo ...)) (if repo repo (forge-get-repository :known?)))))) (topdir (and repo (eieio-oref repo 'worktree))) (buffer nil)) (if (or repo global) nil (error "Cannot determine repository")) (save-current-buffer (set-buffer (setq buffer (forge-topic-get-buffer repo t))) (setq default-directory (or topdir "/")) (setq forge-buffer-repository repo) (setq forge--tabulated-list-columns (or columns forge-topic-list-columns)) (setq forge--tabulated-list-query (cond ((not (functionp fn)) #'(lambda nil (cl-sort ... ... :key ...))) (repo (apply-partially fn repo)) (fn))) (let* ((old (symbol-function #'tabulated-list-revert))) (unwind-protect (progn (fset #'tabulated-list-revert #'ignore) (forge-topic-list-mode)) (fset #'tabulated-list-revert old))) (setq forge--buffer-list-type type) (setq forge--buffer-list-filter filter) (setq forge--buffer-list-global global) (forge-topic-list-refresh) (add-hook 'tabulated-list-revert-hook #'forge-topic-list-refresh nil t) (tabulated-list-init-header) (tabulated-list-print) (if hl-line-mode (progn (hl-line-highlight)))) (switch-to-buffer buffer))
  forge-topic-list-setup(pullreq nil forge--ls-pullreqs nil nil nil)
  forge--pullreq-list-setup(nil forge--ls-pullreqs)
  forge-list-pullreqs()
  funcall-interactively(forge-list-pullreqs)
  command-execute(forge-list-pullreqs record)
  execute-extended-command(nil #("forge-list-pullreqs" 0 19 (ws-butler-chg chg fontified nil)) nil)
  funcall-interactively(execute-extended-command nil #("forge-list-pullreqs" 0 19 (ws-butler-chg chg fontified nil)) nil)
  command-execute(execute-extended-command)

Notification pull backtrace

Debugger entered--Lisp error: (ghub-graphql-error ((message . "Parse error on \"(\" (LPAREN) at [3, 17]") (locations ((line . 3) (column . 17)))))
  signal(ghub-graphql-error (((message . "Parse error on \"(\" (LPAREN) at [3, 17]") (locations ((line . 3) (column . 17))))))
  (if (eq symb 'error) (if (eq (car-safe data) 'http) (signal 'ghub-http-error (let ((code (car (cdr-safe data)))) (list code (nth 2 (assq code url-http-codes)) (and req (progn (or ... ...) (aref ... 6))) payload))) (signal 'ghub-error data)) (signal symb data))
  (let ((symb x966) (data x967)) (if (eq symb 'error) (if (eq (car-safe data) 'http) (signal 'ghub-http-error (let ((code (car ...))) (list code (nth 2 (assq code url-http-codes)) (and req (progn ... ...)) payload))) (signal 'ghub-error data)) (signal symb data)))
  (let* ((x966 (car-safe err)) (x967 (cdr-safe err))) (let ((symb x966) (data x967)) (if (eq symb 'error) (if (eq (car-safe data) 'http) (signal 'ghub-http-error (let ((code ...)) (list code (nth 2 ...) (and req ...) payload))) (signal 'ghub-error data)) (signal symb data))))
  (progn (ignore (consp err)) (let* ((x966 (car-safe err)) (x967 (cdr-safe err))) (let ((symb x966) (data x967)) (if (eq symb 'error) (if (eq (car-safe data) 'http) (signal 'ghub-http-error (let (...) (list code ... ... payload))) (signal 'ghub-error data)) (signal symb data)))))
  ghub--signal-error((ghub-graphql-error ((message . "Parse error on \"(\" (LPAREN) at [3, 17]") (locations ((line . 3) (column . 17))))))
  (if errorback (funcall errorback (or err errors) headers status req) (ghub--signal-error (or err errors)))
  (let* ((errorback (and t (progn (or (progn (and ... t)) (signal 'wrong-type-argument (list ... req))) (aref req 11))))) (if errorback (funcall errorback (or err errors) headers status req) (ghub--signal-error (or err errors))))
  (if (or err errors) (let* ((errorback (and t (progn (or (progn ...) (signal ... ...)) (aref req 11))))) (if errorback (funcall errorback (or err errors) headers status req) (ghub--signal-error (or err errors)))) (ghub--graphql-walk-response req (assq 'data payload)))
  (let* ((headers (ghub--handle-response-headers status req)) (payload (ghub--handle-response-payload req)) (payload (ghub--handle-response-error status payload req)) (err (plist-get status :error)) (errors (cdr (assq 'errors payload))) (errors (and errors (cons 'ghub-graphql-error errors)))) (if (or err errors) (let* ((errorback (and t (progn (or ... ...) (aref req 11))))) (if errorback (funcall errorback (or err errors) headers status req) (ghub--signal-error (or err errors)))) (ghub--graphql-walk-response req (assq 'data payload))))
  (progn (set-buffer-multibyte t) (let* ((headers (ghub--handle-response-headers status req)) (payload (ghub--handle-response-payload req)) (payload (ghub--handle-response-error status payload req)) (err (plist-get status :error)) (errors (cdr (assq 'errors payload))) (errors (and errors (cons 'ghub-graphql-error errors)))) (if (or err errors) (let* ((errorback (and t (progn ... ...)))) (if errorback (funcall errorback (or err errors) headers status req) (ghub--signal-error (or err errors)))) (ghub--graphql-walk-response req (assq 'data payload)))))
  (unwind-protect (progn (set-buffer-multibyte t) (let* ((headers (ghub--handle-response-headers status req)) (payload (ghub--handle-response-payload req)) (payload (ghub--handle-response-error status payload req)) (err (plist-get status :error)) (errors (cdr (assq 'errors payload))) (errors (and errors (cons 'ghub-graphql-error errors)))) (if (or err errors) (let* ((errorback (and t ...))) (if errorback (funcall errorback (or err errors) headers status req) (ghub--signal-error (or err errors)))) (ghub--graphql-walk-response req (assq 'data payload))))) (if (buffer-live-p buffer) (progn (kill-buffer buffer))))
  (let ((buffer (current-buffer))) (unwind-protect (progn (set-buffer-multibyte t) (let* ((headers (ghub--handle-response-headers status req)) (payload (ghub--handle-response-payload req)) (payload (ghub--handle-response-error status payload req)) (err (plist-get status :error)) (errors (cdr (assq ... payload))) (errors (and errors (cons ... errors)))) (if (or err errors) (let* ((errorback ...)) (if errorback (funcall errorback ... headers status req) (ghub--signal-error ...))) (ghub--graphql-walk-response req (assq 'data payload))))) (if (buffer-live-p buffer) (progn (kill-buffer buffer)))))
  ghub--graphql-handle-response((:peer (:certificates (... ...) :certificate (:version 3 :serial-number "0b:89:05:37:12:5f:45:10:d6..." :issuer "C=US,O=DigiCert Inc,CN=Dig..." :valid-from "2023-02-16" :valid-to "2024-03-15" :subject "C=US,ST=California,L=San F..." :public-key-algorithm "EC/ECDSA" :certificate-security-level "High" :signature-algorithm "ECDSA-SHA384" :public-key-id "sha1:b6:3f:03:4b:19:b5:09:..." :certificate-id "sha1:2d:79:6c:90:2d:ad:8a:..." :pem "-----BEGIN CERTIFICATE----...") :key-exchange "ECDHE-RSA" :protocol "TLS1.3" :cipher "AES-128-GCM" :mac "AEAD" :encrypt-then-mac nil)) #s(ghub--graphql-req :url #s(url :type "https" :user nil :password nil :host "api.github.com" :portspec nil :filename "/graphql" :target nil :attributes nil :fullness t :silent nil :use-cookies t :asynchronous t) :forge nil :silent nil :method "POST" :headers (closure (... ... ... ... ...) nil (if ... ... ...)) :handler ghub--graphql-handle-response :unpaginate nil :noerror nil :reader nil :callback (closure (... ...) (data) (ghub--graphql-set-mode-line buf nil) (funcall ... data)) :errorback nil :value nil :extra nil :query (query (... ... ...) (... ... ...) (... ... ...) (... ... ...) (... ... ...) (... ... ...) (... ... ...) (... ... ...) (... ... ...) (... ... ...) (... ... ...) (... ... ...) (... ... ...) (... ... ...) (... ... ...) (... ... ...) (... ... ...)) :query-str "query {\n  _Z2l0aHViLmNvbTp..." :variables nil :until nil :buffer #<buffer magit: fud-ts> :pages 1))
  url-http-activate-callback()
  url-http-chunked-encoding-after-change-function(1194 1320 126)
  url-http-wait-for-headers-change-function(1 1346 1345)
  url-http-generic-filter(#<process api.github.com> "HTTP/1.1 200 OK\15\nServer: GitHub.com\15\nDate: Thu, 07...")
Herschenglime commented 6 months ago

Looking at the error message a little closer, it looks like it might have to do with this call?

(ghub--graphql-req :url #s(url :type "https" :user nil :password nil :host "api.github.com" :portspec nil :filename "/graphql" :target nil :attributes nil :fullness t :silent nil :use-cookies t :asynchronous t)

I will say I'm not too familiar with Elisp so this might not be it, but it seems like the GraphQL request might be getting a left parenthesis from the Lisp code that wasn't properly scrubbed

tarsius commented 6 months ago

Sounds like #639, which should be fixed now.

Herschenglime commented 6 months ago

Oh yup, that fixed it! I had pulled in the updated code but it didn't seem to have taken effect, so it seems like the relevant steps were:

  1. Pull latest forge and ghub
  2. Call forge-reset-database

Closing now, thank you for your help!

tarsius commented 6 months ago

In case somebody else is affected: it's enough to remove the corrupted repositories:

(pcase-dolist (`(,owner ,name ,id)
               (forge-sql [:select [owner name id] :from repository]))
  (when (text-properties-at 1 owner)
    (message "Removing %s/%s" owner name)
    (closql-delete (forge-get-repository :id id))))