Skip to content

Error in $[0].cursorpos: parsing Text failed, expected String, but encountered Number #46

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

Closed
SCLeoX opened this issue Sep 20, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@SCLeoX
Copy link

SCLeoX commented Sep 20, 2021

I am using the WakaTime official vscode extension. I noticed that my extension started to error out since about 3 days ago:

image

My WakaTime extension log is filled with the following error message:

"caller":"/Users/runner/work/wakatime-cli/wakatime-cli/cmd/legacy/run.go:194","func":"runCmd","level":"error","message":"failed to run command: sending heartbeat(s) later due to bad request: bad request at \"https://<My domain>/api/v1/users/current/heartbeats.bulk\"","now":"2021-09-19T21:43:27-04:00","version":"v1.26.0"}

Not very helpful :/

I captured a packet that the extension is sending to my HakaTime instance, and tried to replicate it, so I can see the error message. The response was the following:

{
    "error": "BadRequest",
    "message": "Error in $[0].cursorpos: parsing Text failed, expected String, but encountered Number"
}

Once I changed the fields cursorpos and lineno to strings (wrapping them with quotation marks), the requests went through fine.

P.S. There is also a suspicious update in the WakaTime vscode extension 3 days ago adding the support for those two fields, and I suspect this has something to do with this issue..

P.P.S. I would gladly work on this issue if I can, but for the love of god I cannot understand Haskell.

@mujx
Copy link
Owner

mujx commented Sep 20, 2021

That's a bit unfortunate, because #11 was also meant to handle this inconsistency. Seems like we need a way to handle both numbers and strings for that field.

@mujx mujx added the bug Something isn't working label Sep 20, 2021
@kammerdiener
Copy link

I am seeing this same problem with the VS Code plugin. My zsh plugin works properly but VS Code just fails.

I would also be more than happy to work on it, but having never worked with Haskell before I am probably going to cause more bugs.

@1dotd4
Copy link

1dotd4 commented Oct 8, 2021

Is there any spec that say which data should be sent to the server?

Looks like #16 forced everything to Text, but it's a plugin misalignment rather than a server problem. Aeson is strict when it tries to parse the JSON. Thus I guess either there's a spec that say cursorpos and lineno must be numbers or the parser should be extended to try catching both cases and casting to number (as I think you prefer having numbers over strings).

This is what I could understand by reading the code and the issues linked.

@1dotd4
Copy link

1dotd4 commented Oct 8, 2021

Specs exists, thus the problem is in #16.
It should be reverted to number.

@mujx
Copy link
Owner

mujx commented Oct 9, 2021

@1dotd4 Thanks a lot for taking the time to dive into this.

Indeed the spec exists but it's not really up-to-date or followed. In reality what the upstream wakatime server allows is the actual spec. That's what I had in mind when converting Int to Text.

In order to make hakatime working again with the latest plugin version I will allow both Text and Int. In the future when all the other plugins are compliant I'll revert back to the original schema.

@mujx mujx closed this as completed in 60b229d Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants