Code Monkey home page Code Monkey logo

Comments (11)

bboe avatar bboe commented on June 7, 2024 1

This issue has been brought to the attention of the platform team at Reddit where it would seem there was a recent code change impacting this old endpoint. No ETA on resolution at the moment.

from praw.

LilSpazJoekp avatar LilSpazJoekp commented on June 7, 2024 1

So here's a summary of my findings: (TL;DR Reddit broke something in their /api/morecomments endpoint and there isn't much we can do about it at the moment)

When you call replace_more PRAW will start replacing all MoreComments instances with its children comments. These can be either Comment or MoreComments instances. In posts with a bunch of comments (1k+ comments), the last comment will basically be the overflow of the rest of the comments (which is a MoreComments instance itself). This last instance of MoreComments can have thousands of children comments. Normally, this isn't an issue because you will just need to request the comments for that instance with the /api/morecomments endpoint and you'll get back more comments (which can be a mixture of Comment and MoreComment instances) and the last one will be another large MoreComments instance. This continues until all the instances are replaced or the limit (the number of MoreComments it will replace, by default this is 32) in the replace_more is reached. Side note, the reason why many people are seeing this is because PRAW starts with the biggest MoreComments first.

Now here is where it falls apart, the first time PRAW takes this last MoreComments and hits the /api/morecomments endpoint to fill those in. It gets the expected comments back, however, the last child of that response is another MoreComments instance (notice the count of 17524) that is corrupted/incomplete:

{
    "json": {
        "data": {
            "things": [
                ...,
                {
                    "data": {
                        "children": [],
                        "count": 17524,
                        "depth": 0,
                        "id": "s",
                        "name": "t1_s",
                        "parent_id": "t3_2nbslo"
                    },
                    "kind": "more"
                }
            ]
        },
        "errors": []
    }
}

The assertion that everyone is seeing is there to make sure there is children to actually fetch. And with this incomplete MoreComments instance, this will prevent PRAW from fetching the majority of the comments (basically PRAW can get the first and second page of comments you can see on the site).

We have a few solutions to this:

  • Remove the assertion
    • this will result in an error later on because PRAW tries to fetch an empty set of comments and it isn't written to handle that
  • Remove the bad MoreComments instance
    • This will cause the replace_more to only replace a small subset of MoreComments.

Both of these solutions are not good and our best bet is that Reddit will fix this bug, and soon. I suspect Reddit has made a change without considering the public API because the website seems unaffected by this and there appears to be different format (c1:t1_c60n8gi,t1_xxxxx,t1_xxxxx,) that Reddit is requesting from the /api/morecomments endpoint.

It seems @bboe beat me to the punch on my comment but it just confirms my findings.

from praw.

LilSpazJoekp avatar LilSpazJoekp commented on June 7, 2024 1

This appears to be fixed in my testing earlier today. Though, I couldn't test fully to 100% confirm it is fixed.

from praw.

kuprel avatar kuprel commented on June 7, 2024

I'm also having this issue, and "This code has previously worked as intended": Yes

from praw.

cmurg avatar cmurg commented on June 7, 2024

I'm also having this issue, it works for submissions with small number of comments, but fails with larger ones (~1400 comments) which have previously worked with no errors.

from praw.

maks-IV avatar maks-IV commented on June 7, 2024

Similarly, it is impossible to get comments, this error constantly appears. Is there any workaround?

from praw.

LilSpazJoekp avatar LilSpazJoekp commented on June 7, 2024

Literally just started digging into this like 4 minutes ago lol. I report back with my findings.

from praw.

LilSpazJoekp avatar LilSpazJoekp commented on June 7, 2024

Long story short: there is a point in the building of the forrest that PRAW gets invalid/corrupted data from Reddit.

I'll investigate if this is in response to PRAW sending invalid/corrupted data to Reddit.

from praw.

LilSpazJoekp avatar LilSpazJoekp commented on June 7, 2024

This is a new bug with Reddit. Reddit is returning a response that has the last child's ID truncated to 1 character. @bboe would you mind taking a look?

from praw.

joGaul95 avatar joGaul95 commented on June 7, 2024

In case you receive some update on the ETA, can you inform the thread. I'd be good to know, in case this is long term.

from praw.

LilSpazJoekp avatar LilSpazJoekp commented on June 7, 2024

We certainly will!

from praw.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.