User data archive export fails: undefined method 'url' for an instance of DiscourseDataExplorer::QueryGroup

AI-generated summary

A bug report details a failure in the user data archive export process when users have bookmarked Data Explorer group reports. one1 explains that the Jobs::ExportUserArchive background job crashes with a NoMethodError because it attempts to call .url on DiscourseDataExplorer::QueryGroup instances, which do not implement this method. This issue occurs because bookmarks are polymorphic; while core types like Topics and Posts support the url method, Data Explorer query groups do not.

The report includes reproduction steps: an admin creates a Data Explorer query for a group, a user bookmarks it via the Reports tab, and then requests a data archive. The job fails during the generation of the Bookmarks CSV, preventing the download link from being sent. The backtrace points to export_user_archive.rb where the exception is raised.

Two potential fixes are suggested: implementing a url method on the DiscourseDataExplorer::QueryGroup model or making the core export job defensive by checking if the bookmarkable object responds to url. As a temporary workaround, deleting the specific bookmarks associated with DiscourseDataExplorer::QueryGroup allows the export to complete successfully.

Full Disclosure: I used ask.discourse to compose this bug report after a conversation. Also, I know I’m behind on updates but I wanted to post this while it was still fresh in my mind.

I was able to reproduce this on two different user accounts.

Summary

Requesting a user data archive (Preferences → Export your data → Request archive) fails for users who have bookmarked a Data Explorer group report. The Jobs::ExportUserArchive background job crashes while generating the Bookmarks CSV, so the export never completes and no download link is sent.

Environment

  • Discourse version: 2026.8.0-latest.1
  • Data Explorer: bundled with core (version follows core)
  • Self-hosted / hosted: self-hosted
  • Ruby/Rails stack per backtrace: activemodel/activerecord 8.0.5.1, Sidekiq 7.3.10

Steps to reproduce

  1. As an admin, create a Data Explorer query and grant access to a group.
  2. On the group’s Reports tab, click Bookmark on the query so it becomes a bookmarked group report.
  3. As that same user, go to Preferences → Export your data → Request archive.
  4. Watch the job fail (check Admin → Logs or Sidekiq logs).

Expected behavior

The user archive should be generated and the user should receive the download link, including their bookmarks.

Actual behavior

The export job raises an exception and the archive fails. The backtrace shows the crash occurring in bookmarks_export, where the job calls .url on the bookmarked object:

Job exception: undefined method 'url' for an instance of DiscourseDataExplorer::QueryGroup

Backtrace (abridged to the relevant frames):

activemodel-8.0.5.1/lib/active_model/attribute_methods.rb:512:in 'ActiveModel::AttributeMethods#method_missing'
activerecord-8.0.5.1/lib/active_record/attribute_methods.rb:495:in 'ActiveRecord::AttributeMethods#method_missing'
/var/www/discourse/app/jobs/regular/export_user_archive.rb:325:in 'block in Jobs::ExportUserArchive#bookmarks_export'
activerecord-8.0.5.1/lib/active_record/relation/delegation.rb:101:in 'Array#each'
activerecord-8.0.5.1/lib/active_record/relation/delegation.rb:101:in 'ActiveRecord::Delegation#each'
/var/www/discourse/app/jobs/regular/export_user_archive.rb:319:in 'Jobs::ExportUserArchive#bookmarks_export'
/var/www/discourse/app/jobs/regular/export_user_archive.rb:170:in 'Kernel#public_send'
/var/www/discourse/app/jobs/regular/export_user_archive.rb:170:in 'block (2 levels) in Jobs::ExportUserArchive#execute'
/var/www/discourse/app/jobs/regular/export_user_archive.rb:168:in 'block in Jobs::ExportUserArchive#execute'

Analysis

Bookmarks are polymorphic. The export job calls bookmarkable.url, which works for core bookmarkable types (Topic, Post), but DiscourseDataExplorer::QueryGroup does not implement url, so the job raises NoMethodError on the first such bookmark.

It appears Data Explorer registers query groups as bookmarkable (via the group report Bookmark button), but the model lacks the url method (or the core export job needs a guard for bookmarkable types that don’t provide one).

Suggested fix

Either implement a url method on DiscourseDataExplorer::QueryGroup, or make core’s bookmarks_export defensive (e.g., bookmarkable.respond_to?(:url) / rescue per-row) so a single unsupported bookmarkable type can’t kill the whole export.

Workaround

Deleting the offending bookmarks (rows in bookmarks where bookmarkable_type = 'DiscourseDataExplorer::QueryGroup' for the affected user) allows the export to complete.