marcomaroni-github / twitter-to-bluesky

Import all tweets exported from X/Twitter to a Bluesky account.
Other
146 stars 8 forks source link

ERR_UNESCAPED_CHARACTERS #20

Open grasshoppermouse opened 2 days ago

grasshoppermouse commented 2 days ago

Error after importing 205 tweets (out of ~5K):

(base) hagen@van-vl609-dhcppool-1018932055 twitter-to-bluesky % npm run start_log

> twittertobluesky@0.6.0 start_log
> npx tsc && node app.js > import.log

node:_http_client:182
      throw new ERR_UNESCAPED_CHARACTERS('Request path');
            ^

TypeError [ERR_UNESCAPED_CHARACTERS]: Request path contains unescaped characters
    at new ClientRequest (node:_http_client:182:13)
    at Object.request (node:https:381:10)
    at RedirectableRequest._performRequest (/Users/hagen/Documents/Misc/twitterstuff/twitter-to-bluesky/node_modules/follow-redirects/index.js:326:24)
    at new RedirectableRequest (/Users/hagen/Documents/Misc/twitterstuff/twitter-to-bluesky/node_modules/follow-redirects/index.js:100:8)
    at Object.request (/Users/hagen/Documents/Misc/twitterstuff/twitter-to-bluesky/node_modules/follow-redirects/index.js:532:14)
    at Object.get (/Users/hagen/Documents/Misc/twitterstuff/twitter-to-bluesky/node_modules/follow-redirects/index.js:537:44)
    at /Users/hagen/Documents/Misc/twitterstuff/twitter-to-bluesky/app.js:55:38
    at new Promise (<anonymous>)
    at resolveShorURL (/Users/hagen/Documents/Misc/twitterstuff/twitter-to-bluesky/app.js:53:12)
    at cleanTweetText (/Users/hagen/Documents/Misc/twitterstuff/twitter-to-bluesky/app.js:83:101) {
  code: 'ERR_UNESCAPED_CHARACTERS'
}

Node.js v20.18.0

Last item in import.log:

Discarded (start with @)
Parse tweet id '1453876335642755075'
 Created at 2021-10-29T00:08:24.000Z
 Full text 'https://t.co/flSBgG1zlB…'

I think the actual tweet was this QT: https://x.com/ed_hagen/status/1453876335642755075

marcomaroni-github commented 1 day ago

Hi @grasshoppermouse it seems that the problem is precisely this path "https://t.co/flSBgG1zlB…" that is contained in the text of the tweet, for some reason the three dots at the end of the text have strange characters encoding that send the library that interprets the urls into error by mistakenly including them in the url. While I try to understand how to solve it, try removing the three dots at the end or adding a space between the path and the dots and see if that still gives an error.

grasshoppermouse commented 15 hours ago

After removing the three dots, that tweet didn't throw an error. From the log:

Parse tweet id '1453876335642755075'
 Created at 2021-10-29T00:08:24.000Z
 Full text 'https://t.co/flSBgG1zlB'
 Clean text 'https://twitter.com/EikoFried/status/1453798939929546761?s=20'
{
  '$type': 'app.bsky.feed.post',
  text: 'https://twitter.com/EikoFried/status/1453798939929546761?s=20',
  facets: [ { index: [Object], features: [Array] } ],
  createdAt: '2021-10-29T00:08:24.000Z'
}
Bluesky post create, URL: https://bsky.app/profile/twitterarchive.edhagen.net/post/3l7owtc6hwo2n