~core/follow/ tries to parse non-JSON out of messages.content and explodes #94

Closed
opened 2025-01-01 15:21:12 -05:00 by interfect · 3 comments

Whenever I go to http://127.0.0.1:12345/~core/follow/ on TildeFriends 0.0.26, I get an error:

ERROR:

⚠️ unexpected character
    at <input>:1
    at parse (native)
    at contacts_internal (app.js:27)

here's a screenshot of it happening.

Screenshot 2025-01-01 135156.png

According to the code, it is trying to parse JSON from the content column of the messages table at this point. So something other than JSON has managed to get into that table and also survive the json_extract query on content?

If I stick in:

throw new Error("Boom! " + row.content);

Then I get:

ERROR:

⚠️ Boom! �WGtypewcontactwcontact�5@c1WLS0y45ZnAKogdOQDfOyrGyeMm/pVJhhzCcxCVHbo=.ed25519�ollowing
    at contacts_internal (app.js:27)

Which is indeed not JSON.

Whenever I go to http://127.0.0.1:12345/~core/follow/ on TildeFriends 0.0.26, I get an error: ``` ERROR: ⚠️ unexpected character at <input>:1 at parse (native) at contacts_internal (app.js:27) ``` here's a screenshot of it happening. ![Screenshot 2025-01-01 135156.png](/attachments/bbaff53d-8dd6-4c96-86da-deaaf124b7f8) According to the code, it is trying to parse JSON from the `content` column of the `messages` table at this point. So something other than JSON has managed to get into that table and also survive the `json_extract` query on `content`? If I stick in: ``` throw new Error("Boom! " + row.content); ``` Then I get: ``` ERROR: ⚠️ Boom! �WGtypewcontactwcontact�5@c1WLS0y45ZnAKogdOQDfOyrGyeMm/pVJhhzCcxCVHbo=.ed25519�ollowing at contacts_internal (app.js:27) ``` Which is indeed not JSON.
Author

I think we meant to SELECT json(content) FROM messages AS content, and not SELECT content FROM messages, because internally it is JSONB and you need the function to convert to text.

I think we meant to `SELECT json(content) FROM messages AS content`, and not `SELECT content FROM messages`, because internally it is JSONB and [you need the function to convert to text](https://sqlite.org/json1.html#jmini).
Author

Nope it has to be SELECT json(content) AS content FROM messages, but that works.

Nope it has to be `SELECT json(content) AS content FROM messages`, but that works.
Owner

Yep, that's exactly it. A while back I migrated that column to jsonb and never updated that particular app. Oops! Thanks.

Yep, that's exactly it. A while back I migrated that column to jsonb and never updated that particular app. Oops! Thanks.
cory closed this issue 2025-01-01 15:29:12 -05:00
Sign in to join this conversation.
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cory/tildefriends#94
No description provided.