7

Recently, I posted a comment on a question, which contained a relative link to another question on this site (i.e. a link of the form [link](/questions/3122/formatting-sandbox)). The question was later migrated to Meta Stack Overflow.

Later on, on the migrated question, I received a comment reply from another user asking me why I linked to an answer on that site that was completely unrelated to the thing I was talking about. I was very confused as to why they'd be asking such a question, since I could have sworn that the resource I linked to was at least remotely relevant (if not completely relevant).

After a little investigation, I realized that the domain portion had been rewritten to link to Meta Stack Overflow instead, breaking the link. (The link was correct in that the portion after the site domain was correct.)

This doesn't seem like expected behavior, since the commenter may not be aware of the fact that their question may end up being migrated later and that their relative link would be broken if the question gets migrated. (I was unaware it would be, since normal users can't vote to migrate questions from this site; migration requires a moderator here.)

This might seem like a rather rare occurrence, but given that the SE team has decided to support relative links in other cases, I think this falls under that as well. I often end up with a relative link under the following cases:

  • I have the ID of a question memorized
  • I sometimes use the duplicate dialog to find links to related questions (without actually voting to close); that spits out relative links
  • The comment has a lot of links and would exceed the length limit, but I can shorten it by making links relative (while there are other ways to shorten post URLs, I've hit the length limit even when using all of those)

Also, I believe that this not only applies to comments, but also to posts (the question and any answers) too. (It could be the same if the Markdown is not re-rendered, but if it is, or if the post is rebaked later, it may break.)

Summary: if a question gets migrated, any relative links in the question, answers, and any comments shouldn't become broken links to things on the destination site, but instead remain links to the origin site (as they were back when they were originally posted).

If anyone tries to reproduce this bug for this specific combination of sites, please be sure to use a post ID higher than 250000. Post IDs less than 250000 on Meta Stack Overflow redirect back here, so it may appear to "work" when it actually doesn't (those redirect back here as part of the ).

  • 2
    I have the ID of a question memorized ... okay, how many ID''s have you memorized and what question belongs to id 1337? – rene Sep 27 '19 at 5:08
  • 619 occurrences on SO alone so if any of those get migrated this will lead to confusion on the target site. – rene Sep 27 '19 at 5:17
  • This is a bit related: meta.stackexchange.com/questions/156667/…. You would need to have an option to allow for a larger comment if you want to include the hostname after migration. Or you would need wonky stuff that adds a hostname on comment rendering based on if there is a migration but that needs to only kick in if the comment originated on the target site. Seems far from trivial. – rene Sep 27 '19 at 5:27
  • @rene Relative links can also begin with /a or /posts. – Sonic the Anonymous Hedgehog Sep 27 '19 at 14:54
  • they can start with all possible routes, /users , /review /help. I wasn't aiming at being complete, only to get a rough idea about the numbers involved. I didn't cover post content either. I don't expect we'll find more then 5,000 cases. – rene Sep 27 '19 at 15:57
  • It happens for posts too: meta.stackoverflow.com/posts/370837/revisions – Glorfindel Nov 19 '19 at 8:33
  • But this query seems to suggest it's a rather small problem. I've checked the 8 hits and corrected the only problem. Relative URLs aren't widespread, it seems. (I do realize they might be used more often in comments, but I can't fix those.) – Glorfindel Nov 19 '19 at 10:59

You must log in to answer this question.

Browse other questions tagged .