Topicslug with numbers gets translated into topic id?

So, on our discourse server we use topic slugs like 123-region-2 this has been no issue until recently. Now it seems thats the discourse server, if it gets a request for example 5454-region-3 and that topic slug does not exist. It gets the topic with topic id 5454 and this creates a lot of problems.

Was there an update to this behaviour recently? We usually run launcher rebuild close to once a week so we have 2.3.0.beta5 right now.

Another theory might be that our 123 part in 123-region-2 is always higher than topic ids and they both have just been increasing causing no “collisions” but now that we added another region which starts of from 0 again we almost exclusively get collisions with existing topics.

Is there a way to make sure if we get http://discourse.server.com/t/123-mytopicslug-2.json and that topic does not exist we get a 404?

Why would you even have this form to begin with? Where is the numeric ID of the topic? The URL is malformed the way you’ve written it.

Here’s what it should look like:

https://meta.discourse.org/t/slug/112491

Where slug can be literally any text imaginable, because it doesn’t matter. Only the numeric ID of the topic does.

Starting a title with a number is a bad idea as you describe. The problem is that the slug is ignored by Discourse and that if you start a slug with a number and that number matches a topic_id you’ll get that topic.

These both resolve to this topic

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

https://meta.discourse.org/t/112491-degggrdff

You’ll need to change your convention to use titles like 'region 5454 section 3" rather than 5454-region-3

Oh, but if the final topic id is there, then the right thing happens. Why are you removing the topic_id?

https://meta.discourse.org/t/1234-topicslug-with-numbers-gets-translated-into-topic-id/112491/3
1 Like

We do this lazily, so the client predicts the topic slug. We have no way of predicting the internal discourse topic id.

So we have to get the topic solely based on the slug.

If we change the slug to be region-1-123 instead and that works I guess thats a solution. To clarify, the numbers 1 and 123 here has nothing to do with discourse and are generated elsewhere.

Or, if there is a way to get topic id by topic slug only that would be great in our case.

Right. Then you’ll need to make sure that your titles won’t start with numbers.

I think you can get that from the API. Search “reverse engineer api”

Nice, we only have 37k topic slugs to rename. :smiley::gun:

Renaming 37K topics could be done with a script. If you have a budget for such, post on #marketplace or contact me directly.

Re-training your users to guess new URLs, which would seem much harder. But how did you train them to guess URLs in the first place? Are they coming from some other site that you manage?

1 Like

You kinda buried the lede here. This is the entire question: why do it this broken and non-standard way?

1 Like

Indeed. I got lost on this one a couple different ways.