Removing title from URL breaks links

All three of the following links are to the second post in this topic. However, only the first two work. The third one worked until very recently, and we use it pretty extensively in our community to avoid cluttering wiki posts that reference several posts within the topic. That third link now just loads endlessly and never actually shows the content.

[full title link](https://meta.discourse.org/t/link-to-post-within-same-topic-doesnt-work-if-there-is-no-title-in-the-url/121455/2)
full title link

[short title link](https://meta.discourse.org/t/short/121455/2)
short title link

[no title link](https://meta.discourse.org/t/121455/2)
no title link


P.S. Sorry about not using try.discourse.com earlier. I’ll create an account over there for next time.

1 Like

Second post to demonstrate the bug.

What you’re actually using there is a hack, especially if it is a deep link to a specific post. This is the correct permalink URL form

https://meta.discourse.org/t/{title}/{topic-id}/{post-id}

This has been hacked up to work, when people accidentally omit the topic ID, we guess that if the “topic title” is all numeric, they meant the topic ID:

https://meta.discourse.org/t/{topic-id}

So this works

https://meta.discourse.org/t/121455

but this cannot, for what I hope are obvious reasons

https://meta.discourse.org/t/topic-title

But adding the post number to that is riskier.

I recommend not relying on sort of hacky undocumented behaviors, though, and switching to this formally supported form

https://meta.discourse.org/t/x/121455/2

4 Likes

The third link does work if you open it in a new tab. It’s only when you click within one tab that it breaks. And it breaks bad - you can’t even click the logo to go back to the front page of the forum.

TypeError: Cannot read property 'get' of undefined
    at n.setupController (application-779d3dc401b01d1322f0bf8b26cb0e5f4c83a62f26cbecbd52159a94370dffc3.br.js:68)
    at n.a.setup (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:8)
    at i (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at u.n.routeEnteredOrUpdated (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at u.n.setupContexts (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at u.n.finalizeTransition (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17
    at f (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at T (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at E (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)

Error while processing route: topic.fromParams Cannot read property 'get' of undefined TypeError: Cannot read property 'get' of undefined
    at n.setupController (https://d11a6trkgmumsb.cloudfront.net/assets/application-779d3dc401b01d1322f0bf8b26cb0e5f4c83a62f26cbecbd52159a94370dffc3.br.js:68:14673)
    at n.a.setup (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:8:6889)
    at i (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:23930)
    at u.n.routeEnteredOrUpdated (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:24069)
    at u.n.setupContexts (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:23260)
    at u.n.finalizeTransition (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:22253)
    at https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:21378
    at f (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:29538)
    at T (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:30915)
    at E (https://d11a6trkgmumsb.cloudfront.net/assets/ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17:30814)

Uncaught TypeError: Cannot read property 'cancelFilter' of undefined
    at n.deactivate (application-779d3dc401b01d1322f0bf8b26cb0e5f4c83a62f26cbecbd52159a94370dffc3.br.js:68)
    at n [as deactivate] (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:10)
    at n.a.exit (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:8)
    at u.n.setupContexts (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at u.n.getTransitionByIntent (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at u.n.transitionByIntent (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at u.n.doTransition (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at u.n.intermediateTransitionTo (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:17)
    at n.s.intermediateTransitionTo (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:8)
    at n.a.intermediateTransitionTo (ember_jquery-0ae86c6a7527a99c2b9b8a11521273bd9cb4f7d41bc546df081b7ee94f26d9c3.br.js:8)

Yep, it’s being treated like a permalink redirect and they’re not supported for internal links.

Unfortunately we had no way of knowing that this wasn’t officially supported behavior. As far as we were concerned, it worked. So we used it. I’ll try to let people know not to use that approach from now on, but unfortunately that doesn’t help us now when we have hundreds of these floating around.

As @Dannii said, it only breaks when it’s clicked to load in the same tab, and pretty badly. Even if it’s only really supported for when people do this by accident, doesn’t that still mean it should be fixed? Especially since it works when the topic is different.

You can search your posts for URLs which match a regex. AFAIK you just need to specify anything in the title field, it doesn’t need to be the title but does have to pass something in.

1 Like

You can specify anything for the title, yes. It’s not as simple as finding my posts though. It has become common practice in a portion of our community to remove the title entirely to avoid the verbose urls. So several users would have to fix all of their links.

Why was this moved to support? Having the page spinning endlessly is clearly a bug, even if the fix doesn’t result in titleless URLs working again. And having it work sometimes (links to different posts; direct URL hit in the address bar) but not in this case doesn’t really make sense in my opinion.

1 Like

Because it’s something you need to fix due to unintended use, it was never a supportable thing. A bug is a feature of function that stopped working, which isn’t the case here.

I’ve also updated the title to reflect what actually happened here, links aren’t created without a title, this has arisen because links were either entered by hand or had their titles removed. Discourse isn’t the source of the problem in any sense for it to be a Discourse bug.

You can identify every broken link in one hit by looking through your database, your users don’t need to go back and fix them by hand, but you absolutely do have to re-educate them to stop them from doing this in the future.

2 Likes

I’m not an admin, so unfortunately I can’t do this.

So it’s acceptable for the page to spin forever? Even redirecting to a 404 page would make more sense than that.

That wouldn’t fix your problem though, right?

Long term they need to fix their links, as what they were doing was basically an unsupported hack.

As I said, the topic ID only is indeed an officially supported form (to cover the “oops I forgot the title” case), but topic ID plus post ID is not.

What do you think @eviltrout on what the behavior should be (see third link in first post)?

1 Like

Oh, that’s interesting. What’s the reasoning for treating them differently? Is it not a case that people still forget the title but care about a specific post?

It’s a pretty nasty hack, because we are treating text as numeric. Essentially it is a “wow the user is really confused, I guess we’ll do the best we can” escape hatch. It is not meant to be a primary navigational method people should be relying on, especially once post IDs are also involved.

2 Likes

Is detection only happening at link click? Could we detect it when the post is baked and apply a class to any funky malformed links?

If this is such a big deal for your community why aren’t the admins here discussing it? They’re the ones who will ultimately need to apply any fixes.

2 Likes

It is interesting that the server side case handles it. There is a specific route for /t/:topic_id/:post_number.

The match only happens when topic_id and post_number are numeric. In that case, it will look up the correct topic slug and redirect there.

Since it’s supported on the server side, I think we should have the client side support it too. It doesn’t make sense to show an error page when we can do an AJAX lookup of the correct slug and show it. Having said that, I would discourage people from using those links, because that extra lookup is an extra web request for a mostly pointless reason.

7 Likes

I happened to notice it so I brought it up. It’s a very hands-off community, so I try to only get the admins involved when it’s really important. I’m very active in the community, particularly in the subgroup that would be most affected by this change.

1 Like

Hacky, unintentional, or whatever, I think this bug needs to be fixed. Now that this is revealed trolls could intentionally create these links. Remember it doesn’t just not load the topic, it breaks the whole site.

Here, check out my new game!

1 Like

Not really, since you can press the back button.

Did you want to assign this task to someone @eviltrout

Doesn’t work for me…

After clicking on a bad link all of these stop working:

  • clicking the browser’s back button
  • clicking the logo
  • clicking the topic title
  • searching
  • clicking Latest/Unread/Tags etc from the hamburger menu

The only thing I’ve found that works is clicking a notification. Or refreshing the page.

1 Like