"Page" query string from search engine breaks content

AI-generated summary

A bug was reported where appending a page query string (e.g., ?page=5) to a topic URL on Discourse returns blank content or a 404, even though the topic exists without the parameter. waza first noted the issue, observing that Google had indexed an invalid page URL. Mittineague confirmed the issue persists with and without JavaScript, showing malformed output or broken behavior. sam theorized the root cause was failing to return a proper 404 when a non-existent page is requested — possibly an off-by-one error. waza shared a screenshot of the Google search result that led to the broken link. ryantm confirmed the same issue on another Discourse forum (Pololu), where a Google result pointed to a non-existent page 2, returning a 404. sam investigated the source of the link and later confirmed in post 8 that the issue has been fixed — noting the original topic in the report was deleted. The fix likely ensures proper 404 handling for invalid page parameters and prevents indexing of non-existent pages.

This is broken. Only show blank content.

https://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126?page=5

However, if i omit the page query string, the content is loaded:

https://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126
3 Likes

I tried with JavaScript enabled - not a complete wash out (but Bad) - using the timeline “breaks out” if one thinks to try using it.

I tried with JavaScript disabled - not good - got
Tags: #<Tag:0x007fbb686c7160>

Hmm, I guess the “bug” here is that we are not returning a 404, there is no page 5 on that topic.

1 Like

I see. Seems like Google indexed wrong url?

I get that url from this keyword:

1 Like

I will have a look

This may be an office space class off by one error

1 Like

Hi.

@sam, was this off-by-one issue resolved? I think I may be seeing the same issue because the second link in this Google search

is

https://forum.pololu.com/t/new-products-zumo-shield-and-zumo-robot-kit-for-arduino/5161?page=2

And, clicking on that link gives a 404 because there is no page 2.

Ryan

I need to find where the link is coming from cause I am not seeing it here https://forum.pololu.com/t/new-products-zumo-shield-and-zumo-robot-kit-for-arduino/5161?_escaped_fragment_=true

3 Likes

This has been fixed, topic in OP is deleted.