CSV export of reports is broken

AI-generated summary

The CSV export functionality for various reports in Discourse is broken, resulting in a JavaScript error: Uncaught TypeError: Cannot read property 'category' of null 1. This issue affects reports like likes, topics, posts, and pageviews, particularly when attempting to export data for all categories. The problem was introduced recently, though it previously worked. mbauman reported the issue, and techAPJ confirmed it and provided a fix, which was implemented in two commits 2. j.jaffeux acknowledged responsibility and sam requested testing.

Attempting to export a variety of reports (*.discourse.org/admin/reports/likes and topics and posts and pageviews and more…) yields a javascript error in the console:

Uncaught TypeError: Cannot read property 'category' of null
    at n.exportCsv (_admin-782325fc6304acaa8b3709a0e15ff70a65de97eea7b4b811d6dbe1315e86d3b0.js:4568)
    at e.r._join (_ember_jquery-a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:62460)
    at e.r.join (_ember_jquery-a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:62173)
    at c (_ember_jquery-a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:49023)
    at _ember_jquery-a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:19131
    at h (_ember_jquery-a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:46648)
    at _ember_jquery-a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:19130
    at n.click (_application-555069f6ee111c9cd19c85f6ce9c364b7583a0ba0a2ab416efdcb430428bd5f7.js:45388)
    at n.trigger (_ember_jquery-a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:42680)
    at n [as trigger] (_ember_jquery-a40c13c332a81d765d3281335e4a756ef34f0d72a592a96b7e7b37b022328f29.js:40180)

I can export CSVs for those reports for which I can manually set a category (instead of using the default “all categories”), but of course that’s not terribly helpful when I actually want to export all categories.

This used to work a few months ago but has recently regressed.

I’m using Chrome Version 74.0.3729.131 (Official Build) beta (64-bit) on macOS, but I see the same behavior with Safari, too.

1 Like

@techAPJ can you test this?

4 Likes

Thats mine for sure will fix it today

2 Likes

No worries. I have a simple fix ready, pushing in next 10 mins. :slight_smile:

4 Likes

There were two issues here. Fixed via:

https://github.com/discourse/discourse/commit/002e1f560a657bcc85d6668689da51ef46ab8f2c

and

https://github.com/discourse/discourse/commit/c6409fd2cc98bf53caddbbcfc81359dbd4a820c2

Thanks for reporting this issue @mbauman :+1:

7 Likes