-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incomplete specification of the info and eldoc ops #885
Comments
Another related error with ;; repro.clj
(ns repro)
(def undocumented ;; <- cursor here
123)
Here, the issue is that CIDER expects the Again it's unclear where the responsibility for the fix should lie - on the Elisp side of things, or having the middleware |
I don't think we can possibly guarantee this. What should the returned value be for a Other than that, PR welcome with documentation changes! In case you weren't familiar, the workflow is editing |
Actually, the contents of the response originate from Orchard, which simply assocs :docstring = Ideally, the user-facing Eldoc message should display something like (Also, this was extra confusing because I was under the impression |
Not sure if this would be pretty or desirable, from a user perspective. For clarity, can't we just deal with the empty list Elisp side? |
That's the bit I was unsure about, relying on the fact that Going by the comment here by @bbatsov clojure-emacs/cider#3711 (comment)
Are there other places in the code that implicitly rely on this sort of empty-list = nil punning? For example the (with-current-buffer "repro.clj"
(cider-nrepl-send-sync-request '("op" "ns-path" "ns" "clorjue.core")))
;; =>
(dict "status" ("done")
"id" "22"
"session" "1a73fedf-5506-4623-9ec4-3b93b199f668"
"path" ""
"url" "") But I don't have a broad enough overview of the shapes of data flowing back and forth through all these various ops, and it doesn't help that the docs are incomplete and vague about input / return types. |
Personally I'd advocate for omitting the inclusion of keys that cannot have a meaningul value and return err keys instead. Regardless of bencode intricacies, it feels generally cleaner. In many codebases, return types look like this:
...but one doesn't intentionally include an age of Elisp side, this seems easy to handle - if an expected key is absent or if an err key is present, one handles the error. That's two ways to signal errors, non exclusive. So plenty of chances for consumers to realise what's wrong! Not sure of @bbatsov agrees with me. |
(@yuhan0, sorry for jumping into this issue for my problem, but I thought this thread is most relevant) Hi @vemv, I plan to raise a PR to update the I've encountered an issue with the Basilisp nREPL server and VS Code Calva, where I plan to fix this in the Below is a CIDER log extract showing the return value for an (-->
id "18"
op "info"
session "cdbe8f64-e972-482c-9677-9ae456aaae96"
time-stamp "2024-09-17 18:59:41.733894000"
ns "b"
sym "a/abc"
)
(<--
id "18"
session "cdbe8f64-e972-482c-9677-9ae456aaae96"
time-stamp "2024-09-17 18:59:41.736375000"
arglists-str "[]"
column 1
file "file:/D:/dev/clj/issue-cider-info/src/a.clj"
line 3
name "abc"
ns "a"
resource "a.clj"
status ("done")
) Thanks |
Sounds good, thanks! |
https://docs.cider.mx/cider-nrepl/nrepl-api/ops.html#info
The specification for the
info
op only mentions the following keys in the return message:In reality, the frontend (Emacs / cider-doc) relies on various other compulsory (non-nil) keys in the map, such as
:name
and:ns
.When the
info
op is requested for ill-formed input (eg. a non-existent var), the cider-nrepl implementation signals this by returning:no-info
in its status:cider-nrepl/src/cider/nrepl/middleware/info.clj
Line 129 in 11ae4ee
This is also undocumented, but relied upon by the frontend to guard against parsing of an empty (malformed) var-info response.
https://github.com/clojure-emacs/cider/blob/810337cee931d9f14aa16550a74516f8337a47f3/cider-client.el#L691
(Relevant call stack:
cider-doc-lookup
->cider-create-doc-buffer
->cider-var-info
->cider-sync-request:info
)Similarly, the
eldoc
op implicitly relies on a:no-eldoc
status to signal an empty return value.The problem occurs with the
babashka.nrepl
implementation of the protocol, which also claims to provide theinfo
andeldoc
ops, but sometimes returns an map missing many 'required' keys such as:name
, and adone
status. This results in varying degrees of breakage when CIDER is connected to ababashka
-type REPL.Clearly this would be a simple fix on the impl to return the appropriate
:no-info
/:no-eldoc
statuses, but I thought it would be worth properly pinning down the return contracts before raising an issue there.Otherwise given the current underspecified docs, it could technically be seen as a well-formed response that requires additional logic on the frontend(s) to guard against nil values.
Steps to reproduce (Emacs / Cider 1.15)
cider-jack-in with the
babashka
project type (C-u 3 C-c M-j
)cider-load-buffer
, thencider-doc
on thefoo
symbol.Click the xref link for
bar
in the doc buffer (a non-existent var).The elisp error is thrown:
Wrong type argument: stringp, nil
(Note:
cider-doc
on a non-existent symbol is wrapped in a condition-case, and falls back to a minibuffer prompt on encountering this error)Also observe the broken eldoc displayed in calls to non-existent vars:
Environment & Version information
NA
The text was updated successfully, but these errors were encountered: