Subject: Re: bug#64888: 28.2; jsonrpc.el; Function jsonrpc-error's error code is not correct

From: João Távora <[email-masked]>
Date: Fri, 28 Jul 2023 09:24:45 +0100

On Fri, Jul 28, 2023 at 7:57 AM Eli Zaretskii <[email-masked]> wrote:
>
> > Date: Thu, 27 Jul 2023 15:56:20 +0900
> > From: YI YUE <[email-masked]>
> >
> > I noticed that in jsonrpc.el, the function `jsonrpc-error' will singal a
> > `jsonrpc-error' error
> >
> > with error code 32603, but in JSON-RPC 2.0 Specification[1], the error code is
> > -32603
>
> João, any comments?  It looks like a simple typo to me, or am I
> missing something?

Yes, it's a typo and an outright bug, according to the docstring,
which is correct.

When an Elisp JSONRPC endpoint request handler explicitly signals an
error with the jsonrpc-error function, the mistaken recorded
code is  sent over the wire to the other endpoint.  When it signals
any other error (more common), the correct -32603 is sent.

So this erroneous code is not displayed to the user
(unless debug-on-error is on) nor is it something
that the jsonrpc.el client application can reasonably consume
and hypothetically need to be bug-compatible with.

However, other arbitrary JSONRPC endpoints (outside of Emacs)
may theoretically have grown some expectation of the bugged value
it they're only ever talking to jsonrpc.el backed endpoints.
But I've never seen this and I don't think this is too likely.

So I'd say we should probably fix this without too much worry.

João