Comments (7)
My personal Lemmy instance is running 0.18.0, and lemmy-bot has no problem logging in. However, I'm seeing the FetchError: invalid json response body
error when trying to create a post. Is this possibly related, or am I just doing something wrong?
Starting bot
Initializing DB
logging in
logged in
Marking account as bot account
user_already_exists
Creating post
/app/node_modules/node-fetch/lib/index.js:273
return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));
^
FetchError: invalid json response body at https://lemmy.mydomain.net/api/v3/post reason: Unexpected token 'J', "Json deser"... is not valid JSON
at /app/node_modules/node-fetch/lib/index.js:273:32
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
type: 'invalid-json'
}
from lemmy-bot.
I'm trying to figure out if this is a problem with the bot library, the js client library, or the server-side of the API. I'm seen similar errors of invalid JSON bodies pop up in error toasts on the UI project sometimes.
from lemmy-bot.
The error messages seem to be coming this way because Lemmy API returns plain text instead of JSON. This issue just got closed, so hopefully, the errors will be handled in a more useful way in the next release: LemmyNet/lemmy#3366
However, I still don't know what is triggering the error for me in the first place. I am not that good with Typescript yet, so I am probably doing something wrong, but getting a more reasonable error message should help me as I try to figure it out.
from lemmy-bot.
I am getting this error as well. I have lemmy-bot 0.4.5, node 18.16.1, npm 9.5.1.
I am just learning node, etc... really. I just created a new project, a new index.js in that folder and then copied in the Congratulator bot example, since that's close to what I want to do. I did 'npm init' and 'npm install'. I edited the credentials, and the comment text in the JS file. I run it as 'node index.js' from the terminal and getting the Invalid JSON message above.
Starting bot
Creating database file
Initializing DB
logging in
logged in
Marking account as bot account
user_already_exists
/app/node_modules/node-fetch/lib/index.js:273
return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));
Node.js v18.16.1
Is there anything I can edit on my PC to get this working? Or do we need to wait for the next Lemmy release? Thanks for any pointers.
EDIT TO ADD: Thanks to sylverstream, I added the same console.log() and got this:
Json deserialize error: missing field `post_id` at line 1 column 198
EDIT TO ADD AGAIN: I found a defect in my bot script. It was passing in "postId" but should have passed "post_id". With that fixed, my bot is working! @sylverstream - check your code for a similar mistake, maybe. I think the bot library itself is OK, in other words.
from lemmy-bot.
I've also got the same error. In my case, the logging in fails. I've added a console.log in node_modules/node-fetch/lib/index.js to see the Lemmy response.
I've added this code at line 273 (in the catch block):
console.log(buffer.toString());
In my case the error returned by Lemmy.world is: Json deserialize error: missing field username_or_email at line 1 column 1
@SleeplessOne1917 hopefully that helps?
from lemmy-bot.
The error messages seem to be coming this way because Lemmy API returns plain text instead of JSON. This issue just got closed, so hopefully, the errors will be handled in a more useful way in the next release: LemmyNet/lemmy#3366
However, I still don't know what is triggering the error for me in the first place. I am not that good with Typescript yet, so I am probably doing something wrong, but getting a more reasonable error message should help me as I try to figure it out.
I wonder, are we still waiting on an update to Lemmy before this is addressed?
For me this only happens when trying to pin a post using Lemmy-Frank-Bot.
from lemmy-bot.
I wonder, are we still waiting on an update to Lemmy before this is addressed?
Lemmy version 0.19.0 is going to release (hopefully) this week, so hopefully this will allow us to check whether this is an issue with the API or the bot.
from lemmy-bot.
Related Issues (20)
- Program stops after some time with ETIMEDOUT error. HOT 12
- getUserId and getCommunityId dont always find the user/community HOT 2
- Add a dryrun mode for development
- How to identify if a person is a mod in the community? HOT 2
- Spam of logging in and other stuff HOT 3
- 0.18.1-rc.4 Is broke the bot totally HOT 10
- Bot creates a 502 Error
- Getting `user_already_exists` error after login HOT 6
- No editComment or editPost Bot Action? HOT 10
- First fetch works second not anymore HOT 6
- BotAction to follow a community
- Support for the resolveObject method as a BotAction HOT 1
- SQLITE_BUSY: database is locked HOT 5
- Detect if Post URL / Image / Title / Body changed? HOT 3
- Possible spam of (almost) useless console.log HOT 2
- Get Community (and Instance) Info/Sidebar HOT 1
- just sits at "user_already_exists"
- [Feature request] Optional flag to disable logs HOT 2
- How to list user posts & comments ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lemmy-bot.