Sidebar activation issues after recent Doc Categories update

AI-generated summary

After recent updates to the Doc Categories plugin, MachineScholar reported that the sidebar fails to activate on their site running Discourse 3.6.0.beta1-dev with the Horizon theme. Despite rebuilding the launcher and running bundle exec rake doc_categories:build_sidebar, no errors appeared in logs, and the sidebar remained inactive. pmusaraj acknowledged the issue, and nat suggested checking the database for index, section, and link data via Data Explorer, while also considering cache delays. MachineScholar confirmed the issue persisted beyond cache expiration and shared debug output via PM. nat later clarified that the rake task failed due to a database access error — ActiveRecord::NoDatabaseError — which commonly occurs on self-hosted setups when not run as the discourse user. The fix was to run: sudo -E -u discourse bundle exec rake doc_categories:build_sidebar. MachineScholar confirmed this resolved the issue, successfully creating the necessary sections and links. The root cause was permissions-related, not a plugin bug.

As of these changes to Doc Categories

the sidebar no longer activates. I am running version 3.6.0.beta1-dev (17d735b3ad) with the Horizon theme, and there is nothing in the error logs. I also ensured there is a set index topic, rebuilt the launcher, and ran bundle exec rake doc_categories:build_sidebar.

2 Likes

Thanks for the report, we will take a look shortly.

2 Likes

Oh no, that’s not great.

Do you still have the output of bundle exec rake doc_categories:build_sidebar? (Feel free to send me a PM if it’s private)

So far I have not seen issues here on Meta + Horizon but there could be a state I am missing. If you have data explorer, can you check if there are indexes, sections, and links created?

query
SELECT
  i.category_id,
  i.index_topic_id,
  sec.section_names,
  lnk.section_links
FROM doc_categories_indexes i
LEFT JOIN LATERAL (
  SELECT
    string_agg(COALESCE(s.title, ''), ', ' ORDER BY s.position) AS section_names
  FROM doc_categories_sidebar_sections s
  WHERE s.index_id = i.id
) AS sec ON TRUE
LEFT JOIN LATERAL (
  SELECT
    string_agg(l.href, ', ' ORDER BY s.position, l.position) AS section_links
  FROM doc_categories_sidebar_sections s
  LEFT JOIN doc_categories_sidebar_links l
    ON l.sidebar_section_id = s.id
  WHERE s.index_id = i.id
) AS lnk ON TRUE
ORDER BY i.category_id, i.index_topic_id;

One vector is the site cache. Since categories are cached for 30 minutes, the update may have happened and the regular sidebar is cached prior to the running of the rake task.

1. migration to table
2. cache miss -> sees normal sidebar instead of docs sidebar
3. rake task to build sidebar
4. should see rebuilt sidebar

Technically, (4) should happen and reset the cache. If that’s the issue, you should be seeing them by now.

3 Likes

Thanks for the quick reply! It seems not to be the cache as the issue is persisting. I’m sending you a PM with the Data Explorer query results and the bundle exec rake doc_categories:build_sidebar output. It aborts with a fatal

2 Likes

Just a report back for future onlookers that the rake task that was run in OP was using

bundle exec rake doc_categories:build_sidebar

and met with the error

ActiveRecord::NoDatabaseError: We could not find your database: discourse. Available database configurations can be found in config/database.yml. (ActiveRecord::NoDatabaseError)

Depending on self-hosted setups, it is likely that the task needs to be run with the discourse user to get to the database.

sudo -E -u discourse bundle exec rake doc_categories:build_sidebar

@MachineScholar has confirmed that the sections and links have thus been successfully created. :ok_hand:t2:

4 Likes

This topic was automatically closed after 3 days. New replies are no longer allowed.