Rishikant181 / Rettiwt-API

A CLI tool and an API for fetching data from Twitter for free!
https://rishikant181.github.io/Rettiwt-API/
MIT License
486 stars 46 forks source link

Cannot read properties of undefined (reading 'rest_id') #626

Closed sodamnfoolish closed 1 month ago

sodamnfoolish commented 1 month ago

hey, looks like sometimes twitter sends invalid response on user.replies.

on 4.1.0 version got Cannot read properties of undefined (reading 'rest_id') on latest one got One or more validation error(s) occured, check details field.

[
  ValidationErrorDetails {
    field: 'results',
    constraints: [ 'results must be empty' ]
  }
]

found that sometimes tweet.quoted_status_result is {} on this line

Screenshot 2024-10-16 at 2 39 55 PM
sodamnfoolish commented 1 month ago

hot fix base on 4.1.0 version

Rishikant181 commented 1 month ago

Sorry for the late reply.

Thanks for the hotfix. I did discover the cause of the issue, unfortunately, I've been a lot busy lately so couldn't find the time to work on it. I'll try to merge the hotfix from your fork, which will will buy me time for working on a solution.

Thanks for the contribution and feedback. Means a lot.

matgott commented 1 month ago

Hey! I'm playing around with this package (thank you btw!) and I'm facing the same problem with the search method.

Debugging I found that in the constructor of the Tweet class is checking for tweet.quoted_status_result to assign the value for quoted:

this.quoted = tweet.quoted_status_result ? new Tweet(tweet.quoted_status_result.result) : undefined;

But I got a case where tweet.quoted_status_result was an empty object {} so it was trying to do new Tweet({}) ending in the previous error because the property result wasn't found in quoted_status_result:

image

Logs:


[Rettiwt-API] [2024-10-16T19:53:51.363Z] [AUTHORIZATION] {"authenticated":true}
[Rettiwt-API] [2024-10-16T19:53:51.363Z] [VALIDATE] {"target":"FETCH_ARGS"}
[Rettiwt-API] [2024-10-16T19:53:51.363Z] [GET] {"target":"HTTPS_AGENT"}
[Rettiwt-API] [2024-10-16T19:53:51.363Z] [GET] {"target":"USER_CREDENTIAL"}
[Rettiwt-API] [2024-10-16T19:53:52.127Z] [DESERIALIZE] {"id":"1844376999810433054"}
[Rettiwt-API] [2024-10-16T19:53:52.127Z] [DESERIALIZE] {"id":"1844369358476439922"}
[Rettiwt-API] [2024-10-16T19:53:52.127Z] [DESERIALIZE] {"id":"1844364557973848458"}
...\fetch-tweet\node_modules\rettiwt-api\dist\models\data\Tweet.js:21
        this.id = tweet.rest_id;
                        ^

TypeError: Cannot read properties of undefined (reading 'rest_id')```
Rishikant181 commented 1 month ago

Issue has been fixed. Please upgrade rettiwt-api to v4.1.2.

Rishikant181 commented 1 month ago

There was a "Maximum call stack exceeded" error while deserializing tweet(s) in v4.1.2.

Please upgrade to v4.1.3 instead.