Nested replies: a topic bookmark on a fully read topic 404s and leaves the topic with an empty bookmark list

Version 2026.10.0-latest (a51251632c), nested_replies_enabled, default sort old. The route code involved looks the same on current main.

Steps

  1. Bookmark a topic (topic-level bookmark) that uses the nested view, and read it to the end.
  2. Open that topic normally, then go to a topic list such as /latest, without reloading the page.
  3. Open the user menu, go to the Bookmarks tab and click the bookmark.

Expected: the topic opens and the bookmark button shows “Edit bookmark”.
Actual: no replies are shown, the button shows “Bookmark”, and clicking it shows “Sorry, an error has occurred.” With a fresh page load instead of step 2, the button is right but the topic still shows no replies.

What happens

  • UserTopicBookmarkSerializer#bookmarkable_url links to last_read_post_number + 1. For a fully read topic that post doesn’t exist. Example: /t/slug/818/2 when highest_post_number is 1. The flat view jumps to the nearest post, but the nested route requests /n/slug/818/context/2.json, which returns 404.
  • In routes/topic/from-params.js, if topic.is_nested_view is already set, postStream.refresh is skipped. The 404 from the nested load then sets _loading_error and setupController returns early, so the topic controller keeps the store record exactly as it was.
  • That record’s bookmarks is []. A topic list load runs Topic.munge with list JSON, which has bookmarked but no bookmarks, and munge sets bookmarks = e.bookmarks || [] on the cached record. The button reads bookmarks, so it offers to create a new topic bookmark. Presumably the server rejects that because one already exists.

This is the same failure path as Link to nested topic in my suggested topics doesn't work, whose fix covered suggested-topic links only.

Possible fixes: let the context endpoint or the route fall back to the nearest existing post, as the flat view does, and/or don’t keep the previous topic state when _loading_error is set. Limiting bookmarkable_url to highest_post_number would also remove this trigger.

2 likes

Just for transparency: this bug was found by my colleague and I, but tracing the exact reproduction steps and reporting the issue was done by an AI agent. Apologies if any standards were not followed correctly.