Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2022-09

JSON RPC changes in 3.3.1

15 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Hairy Pixels

So I got the project building after changing the enums but now after running the server breaks after sending the first request and I get the error "'No class "initialize" with method "initialize" was found”.

Here’s a little snippet of the messages I got back but I don’t even know where to start debugging this or what I could post here. Given that, maybe I should start by looking at some release notes for what changed in the JSON RPC library since 3.2.2? There must have been another breaking change that I don’t know it, or it’s related to building with the ARM 64 architecture (can build a x86 3.3.1 on my Mac M1 I think but I haven’t tried yet).

:: --> pascal-language-server initialize(1): (… too long, clipped out ...) :: <~~ pascal-language-server 6: {'message': 'Parameters must be passed in an object or an array.', 'code': -32602} :: -> pascal-language-server exit: None
:: <~~ pascal-language-server 1: {'message': 'No class "initialize" with method "initialize" was found.', 'code': -32601}

Regards,
Ryan Joseph

Reply by email

Hairy Pixels
to Luca Olivetti
Show quoted text 5 lines
On Sep 28, 2022, at 1:34 PM, Luca Olivetti via fpc-pascal wrote: Maybe related to this? https://lists.freepascal.org/pipermail/pas2js/2022-September/001111.html

The question then is did they change something in 3.3.1 in regards to how parameters can be sent? The error "Parameters must be passed in an object or an array.” Suggests maybe I was sending the params as some other type and this is now illegal in 3.3.1.

Regards,
Ryan Joseph

Reply by email

Hairy Pixels
to Hairy Pixels
On Sep 28, 2022, at 1:51 PM, Hairy Pixels wrote: The question then is did they change something in 3.3.1 in regards to how parameters can be sent? The error "Parameters must be passed in an object or an array.” Suggests maybe I was sending the params as some other type and this is now illegal in 3.3.1.

Quick update. I’m very confused now but I deleted the build folder along with the old exec and now I’m getting a similar error on 3.2. I don’t know what happened but I think I was building against some old object files or something. So something changed but I’m still not sure what.

What does that error "'Cannot convert data from object value’” mean exactly?

:: <~~ pascal-language-server 1: {'message': 'Cannot convert data from object value', 'code': -32603} :: --> pascal-language-server shutdown(2): None
:: <~~ pascal-language-server 2: {'message': 'Parameters must be passed in an object or an array.', 'code': -32602} :: -> pascal-language-server exit: None
pascal-language-server: invalid response -> {"jsonrpc":"2.0","error":{"code":-32602,"message":"Parameters must be passed in an object or an array."},"id":null}

Regards,
Ryan Joseph

Reply by email

Hairy Pixels
to Hairy Pixels

Ok I narrowed down this bug I get with 3.2.2 to TJSONParser.

I’m so confused as to what changed. FormatJSON prints the JSON as expected but AsString crashes and gives the error I was seeing from the RPC which it trapped as an exception. When it’s send across the RPC layer it must call AsString and then blow up thus giving me this error.

The JSON in question printed from FormatJSON is valid and can be opened in a JSON editor even so I know it’s ok.

===========================

Request := TJSONParser.Create(Content, DefaultOptions).Parse;
writeln(Request.FormatJSON);  // this prints the JSON correctly (Request ClassName is TJSONObject)
writeln(Request.AsString);

gives this error:

An unhandled exception occurred at $00000001050261A7: EJSON: Cannot convert data from object value
$00000001050261A7

Regards,
Ryan Joseph

Reply by email

Luca Olivetti
to Hairy Pixels: The question then is did they change something in 3.3.1 in regards to how parameters can…

El 28/9/22 a les 8:51, Hairy Pixels via fpc-pascal ha escrit:

Show quoted text 9 lines
> On Sep 28, 2022, at 1:34 PM, Luca Olivetti via fpc-pascal wrote: > > Maybe related to this? > > https://lists.freepascal.org/pipermail/pas2js/2022-September/001111.html The question then is did they change something in 3.3.1 in regards to how parameters can be sent? The error "Parameters must be passed in an object or an array.” Suggests maybe I was sending the params as some other type and this is now illegal in 3.3.1.

In my case there was no parameter at all (since it was an empty array), which is either a fault of the client library (pas2js) or of the server (which should not consider it as an error if the method needs no parameters).
For the time being I modified my code to send a dummy parameter.

Bye

Luca

Reply by email

Sven Barth
to Hairy Pixels: Ok I narrowed down this bug I get with 3.2.2 to TJSONParser. I’m so confused as to what…

Hairy Pixels via fpc-pascal schrieb am
Mi., 28. Sep. 2022, 16:17:

Show quoted text 25 lines
Ok I narrowed down this bug I get with 3.2.2 to TJSONParser. I’m so confused as to what changed. FormatJSON prints the JSON as expected but AsString crashes and gives the error I was seeing from the RPC which it trapped as an exception. When it’s send across the RPC layer it must call AsString and then blow up thus giving me this error. The JSON in question printed from FormatJSON is valid and can be opened in a JSON editor even so I know it’s ok. =========================== Request := TJSONParser.Create(Content, DefaultOptions).Parse; writeln(Request.FormatJSON); // this prints the JSON correctly (Request ClassName is TJSONObject) writeln(Request.AsString); gives this error: An unhandled exception occurred at $00000001050261A7: EJSON: Cannot convert data from object value $00000001050261A7

How about you provide a more complete example instead of making us guess so that we can reproduce it?

Regards,
Sven

Reply by email

Michael Van Canneyt
to Hairy Pixels: Ok I narrowed down this bug I get with 3.2.2 to TJSONParser. I’m so confused as to what…
Hairy Pixels wrote 18 lines
Ok I narrowed down this bug I get with 3.2.2 to TJSONParser. I’m so confused as to what changed. FormatJSON prints the JSON as expected but AsString crashes and gives the error I was seeing from the RPC which it trapped as an exception. When it’s send across the RPC layer it must call AsString and then blow up thus giving me this error. The JSON in question printed from FormatJSON is valid and can be opened in a JSON editor even so I know it’s ok. =========================== Request := TJSONParser.Create(Content, DefaultOptions).Parse; writeln(Request.FormatJSON); // this prints the JSON correctly (Request ClassName is TJSONObject) writeln(Request.AsString); gives this error: An unhandled exception occurred at $00000001050261A7: EJSON: Cannot convert data from object value

Of course, as AsString will not work on a TJSONObject. AsString will only work on the simple types, not on the object or array types or null.

Michael.

Reply by email

Michael Van Canneyt
to Hairy Pixels: The question then is did they change something in 3.3.1 in regards to how parameters can…
Hairy Pixels wrote 12 lines
> On Sep 28, 2022, at 1:34 PM, Luca Olivetti via fpc-pascal wrote: > > Maybe related to this? > > https://lists.freepascal.org/pipermail/pas2js/2022-September/001111.html The question then is did they change something in 3.3.1 in regards to how parameters can be sent? The error "Parameters must be passed in an object or an array.” Suggests maybe I was sending the params as some other type and this is now illegal in 3.3.1.

The 'must send params as object or array' error means exactly what it says: you didn't send params as an object or an array.
Or maybe you didn't send can't help further if you don't show the exact request.

The error "Can't find class 'initialize' with method 'initialize'" is an error (uninitialized variable) that has now been fixed.

Michael.

Reply by email

Michael Van Canneyt
to Michael Van Canneyt: Of course, as AsString will not work on a TJSONObject. AsString will only work on the…
Michael Van Canneyt wrote 28 lines
On Wed, 28 Sep 2022, Hairy Pixels via fpc-pascal wrote: > Ok I narrowed down this bug I get with 3.2.2 to TJSONParser. > I’m so confused as to what changed. FormatJSON prints the JSON as expected > but AsString crashes and gives the error I was seeing from the RPC which it > trapped as an exception. When it’s send across the RPC layer it must call > AsString and then blow up thus giving me this error. > > The JSON in question printed from FormatJSON is valid and can be opened in > a JSON editor even so I know it’s ok. > > =========================== > > Request := TJSONParser.Create(Content, DefaultOptions).Parse; > > writeln(Request.FormatJSON); // this prints the JSON correctly (Request > ClassName is TJSONObject) > > writeln(Request.AsString); > gives this error: > > An unhandled exception occurred at $00000001050261A7: > EJSON: Cannot convert data from object value Of course, as AsString will not work on a TJSONObject. AsString will only work on the simple types, not on the object or array types or null.

Small addendum: Request.AsJSON will of course always work.

Michael.

Reply by email

Hairy Pixels
to Michael Van Canneyt: Of course, as AsString will not work on a TJSONObject. AsString will only work on the…
On Sep 28, 2022, at 10:32 PM, Michael Van Canneyt wrote: Of course, as AsString will not work on a TJSONObject. AsString will only work on the simple types, not on the object or array types or null.

Of course. :P Ok I was just being stupid and let one of those calls slip in as I was debugging. I don’t have a way to test this language server yet which I can run a debugger from so I’m using writeln’s.

So actually this is not a problem and it’s still only the original error I get with 3.3.1. I’ve tracked it down now to the ExecuteMethod call but I may need to get a simple example project for anyone to look at so I can know what changed between versions.

    // Execute method. Finds handler, and returns response.
    Function ExecuteMethod(Const AClassName, AMethodName : TJSONStringType; Params,ID : TJSONData; AContext : TJSONRPCCallContext) : TJSONData; virtual;

Regards,
Ryan Joseph

Reply by email

Michael Van Canneyt
to Hairy Pixels
Hairy Pixels wrote 8 lines
> On Sep 28, 2022, at 10:56 PM, Michael Van Canneyt wrote: > > The error "Can't find class 'initialize' with method 'initialize'" is an > error (uninitialized variable) that has now been fixed. You mean you just fixed it in trunk? I hope so. It was driving me crazy trying to figure out went wrong.

Yes. It was committed & pushed yesterday.

Michael.

Reply by email

Hairy Pixels

Yes you indeed fixed it! Thanks again.

Show quoted text 19 lines
On Sep 29, 2022, at 9:35 PM, Michael Van Canneyt wrote: First see if it fixes your problem, then thank me ;-) Michael. On Thu, 29 Sep 2022, Hairy Pixels wrote: > Thanks Michael! > >> On Sep 29, 2022, at 9:29 PM, Michael Van Canneyt via fpc-pascal wrote: >> >> Yes. It was committed & pushed yesterday. >> > > Regards, > Ryan Joseph >

Regards,
Ryan Joseph

Reply by email