I am filing this as a bug report but I am not sure if the "bug" is on the SEDE side or the chat side (or if this should be a chat feature request).
Issue: SEDE links to answers (or anything that isn't a question for that matter) in the [Post Link]
column are not compatible with chat one-boxing.
Reason: SEDE always uses http://site/questions/id
, no matter what the PostTypeId
is (i.e. instead of http://site/a/id
for answers).
SE's web servers seem to handle this properly and forward to the correct URL, but chat does not, and copying a generated answer link from SEDE into chat does not create a onebox as I would expect.
This is one way to frame the reason. It could also be said that chat does not handle 301's properly. Like I said, not sure where to consider the issue to be.
Also, rene's comment below leads me to point another finger at chat: It turns out chat does properly one-box links to answers in the form /q/id
, it just doesn't handle /questions/id
.
Steps:
- In an SEDE query with a
[Post Link]
column linking to an answer, copy the link and paste it in chat.
Expected: One-box. Actual: No one-box (a ... zero-box?)
Possible Solutions:
- Make SEDE generate
[Post Link]
URLs based onPostTypeId
, or - Make chat be able to one-box
/questions
links to answers, or - Make chat follow the 301 status replies the server sends back before one-boxing, or
- Make SEDE generate links of the form
/q/id
instead of/questions/id
.
The first solution probably comes at too high a cost: While the links are formatted client-side, the query needs to return the title
column in the response when the magic column is present. Letting it be based on PostTypeId
means adding extra overhead to the response when the magic column is used.
I believe that the third solution (follow 301 replies) is philosophically the best except that in practice it isn't really necessary since chat doesn't seem to one-box wiki or moderator nomination posts anyways (PostTypeId
3 thru 8), so unless support for those were added in general it wouldn't change anything vs. the other two options.
The fourth solution is from rene's observation in the comment below. This might be the quickest fix, since it doesn't really require changes to anything other than SEDE's client-side link formatting code.
Also I'm not entirely sure about my claim that the web servers handle /questions
properly for all post types, I'd need to do some more thorough testing, and I don't want to stray too far from the topic here (answer links). I can only say for certain that it works for questions and answers.
Example:
SELECT TOP 2 Id [Post Link], Id, PostTypeId
FROM Posts
WHERE PostTypeId = 1 AND DeletionDate IS NULL
UNION SELECT TOP 2 Id [Post Link], Id, PostTypeId
FROM Posts
WHERE PostTypeId = 2 AND DeletionDate IS NULL
Chat results:
select id as [Post Link] from posts
, it's the server that adds the extra needed info to the response: The response to that query includes the title column queried from the db. So it wouldn't be unreasonable to have it add posttypeid as well, the server is already querying for the extra info needed for the client to build the link. Good catch with \q\. I'm leaning even more towards calling this a chat issue now.SELECT TOP 2 Id **AS** [Post Link]
?