NodeBB's superpower: broken End key
-
In the topic https://what.thedailywtf.com/topic/23697/what-your-superpower-it-is/, when I hit End, the URL updates to match the end of the thread (41 at the time of posting), but it always loads me to post 17 instead. Going to post 41 directly works fine though.
cc @ben_lubar
-
I suspect that there's some sort of problem with post #41 -- I can't get it to load in for me at all.
-
@izzion Yeah, something weird there, for sure. @blubar!
-
@raceprouk said in NodeBB's superpower: broken End key:
when I hit @end ,
I strangely don't have an issue with that
-
@luhmann It's been resolved. Whether by itself or some dwarfish intervention, I think we'll probably never know.
-
@boomzilla Ben told me last night he was working on an NodeBB database issue that would have never occurred in a sanely-designed database, was probably this.
-
@blakeyrat Agreed.
-
-
.............. HOW?
How does it not just fail to load post 41, and instead show post 42+?
"Oh no, one post doesn't work FUCK THE ENTIRE THREAD!" - NodeBB
-
@lorne-kates said in NodeBB's superpower: broken End key:
.............. HOW?
How does it not just fail to load post 41, and instead show post 42+?
"Oh no, one post doesn't work FUCK THE ENTIRE THREAD!" - NodeBB
What happened was the topic's post count was one higher than the number of posts in the topic. You can reproduce the behavior by pushing @end and then replacing the last number in the address bar with a number that is higher. Basically, it puts you on the last "page" of the topic regardless of how many posts there are after the first post on the last page.
-
@ben_lubar said in NodeBB's superpower: broken End key:
@lorne-kates said in NodeBB's superpower: broken End key:
.............. HOW?
How does it not just fail to load post 41, and instead show post 42+?
"Oh no, one post doesn't work FUCK THE ENTIRE THREAD!" - NodeBB
What happened was the topic's post count was one higher than the number of posts in the topic. You can reproduce the behavior by pushing @end and then replacing the last number in the address bar with a number that is higher. Basically, it puts you on the last "page" of the topic regardless of how many posts there are after the first post on the last page.
I thought that was fixed a long time ago based on a bug I reported. URL number > page count or something, it fucked up instead of just going to the last page / post.
But let me guess, NodeBB either regressed that fix, or broke it in a different way.
-
@lorne-kates said in NodeBB's superpower: broken End key:
@ben_lubar said in NodeBB's superpower: broken End key:
@lorne-kates said in NodeBB's superpower: broken End key:
.............. HOW?
How does it not just fail to load post 41, and instead show post 42+?
"Oh no, one post doesn't work FUCK THE ENTIRE THREAD!" - NodeBB
What happened was the topic's post count was one higher than the number of posts in the topic. You can reproduce the behavior by pushing @end and then replacing the last number in the address bar with a number that is higher. Basically, it puts you on the last "page" of the topic regardless of how many posts there are after the first post on the last page.
I thought that was fixed a long time ago based on a bug I reported. URL number > page count or something, it fucked up instead of just going to the last page / post.
But let me guess, NodeBB either regressed that fix, or broke it in a different way.
Well at least it doesn't fuck up anymore. It just goes to the last page instead of the last post.
-
@ben_lubar said in NodeBB's superpower: broken End key:
Well at least it doesn't fuck up anymore. It just goes to the last page instead of the last post.
https://what.thedailywtf.com/topic/23713/nodebb-s-superpower-broken-end-key/12a
-
Prediction: "But the parser obviously can't handle 12a because of regex".
Actually: https://what.thedailywtf.com/topic/23713/nodebb-s-superpower-broken-end-key/-1
-
@lorne-kates That's a silly complaint. It's like saying you went to https://what.thedailywtf.com/user/lorne-kates/give-me-money and instead got a
404 Fuck You
and saying that's a bug, when that URL was never supported and nobody ever promised it.
-
@dkf said in NodeBB's superpower: broken End key:
@lorne-kates That's a silly complaint. It's like saying you went to https://what.thedailywtf.com/user/lorne-kates/give-me-money and instead got a
404 Fuck You
and saying that's a bug, when that URL was never supported and nobody ever promised it.It isn't silly.
The url re writer takes the chunk in the middle and parses it out into a slug, which determines the page.
It then takes the next piece of the url... /12 or /12a... And makes that the post target.
In effect, page.php?slug= superpower& post_id=12a
It should successfully load the thread, but when doing is_int on the post id, should fail, and use the default value. That would be first post, presumably, based on what happens when you put -1 in the url.
Instead, it looks like it's trying to cast the value to an int without type checking and/or error handling, and instead has an uncaught exception, and throws an incorrect 404
Hence, bug.
-
@lorne-kates said in NodeBB's superpower: broken End key:
It should successfully load the thread, but when doing is_int on the post id, should fail, and use the default value.
Why? You're asking for post 12a, which doesn't exist, therefore cannot be found. And if something cannot be found, you return
404 Not Found
. That's why it's called404 Not Found
.@lorne-kates said in NodeBB's superpower: broken End key:
That would be first post, presumably, based on what happens when you put -1 in the url.
This is the bug: that should also return
404 Not Found
.
-
@raceprouk said in NodeBB's superpower: broken End key:
@lorne-kates said in NodeBB's superpower: broken End key:
It should successfully load the thread, but when doing is_int on the post id, should fail, and use the default value.
Why? You're asking for post 12a, which doesn't exist, therefore cannot be found. And if something cannot be found, you return
404 Not Found
. That's why it's called404 Not Found
.@lorne-kates said in NodeBB's superpower: broken End key:
That would be first post, presumably, based on what happens when you put -1 in the url.
This is the bug: that should also return
404 Not Found
.Any integer is allowed in the post index. That allows you to do things like putting 99999999 there to go to the last page.
It also means that if you delete a post, the topic doesn't stop responding to requests for other posts that came later.
-
@ben_lubar said in NodeBB's superpower: broken End key:
Any positive integer is allowed in the post index. That allows you to do things like putting 99999999 there to go to the last page.
It also means that if you delete a post, the topic doesn't stop responding to requests for other posts that came later.
That makes sense, but a post index of -1 or 12a never makes sense, so should behave the same.
-
@raceprouk said in NodeBB's superpower: broken End key:
@ben_lubar said in NodeBB's superpower: broken End key:
Any positive integer is allowed in the post index. That allows you to do things like putting 99999999 there to go to the last page.
It also means that if you delete a post, the topic doesn't stop responding to requests for other posts that came later.
That makes sense, but a post index of -1 or 12a never makes sense, so should behave the same.
Pull requests accepted. The system currently considers -1 the same way it does 99999999 - a valid integer that is outside of the valid range.
-
@raceprouk said in NodeBB's superpower: broken End key:
Why? You're asking for post 12a, which doesn't exist, therefore cannot be found. And if something cannot be found, you return 404 Not Found. That's why it's called 404 Not Found.
I disagree. I'm asking for post12a (which doesn't exist) from thread
blah-blah-motherfucker
, which DOES exist.It'd be like returning a 404 for
page.php?page_id=1#anchor12a
At the very least, it should return an error saying "The thread exists, but the post does not. Click HERE to return to the thread".
But then why annoy the user with a click. Instead, just treat an invalid post ID the same way you tread an out-of-range post ID-- going to the first post.