Links to CSVs in automation data explorer PMs are 404s

AI-generated summary

The discussion revolves around an issue with links to CSVs in automation data explorer PMs returning 404s. T_Disco reported the issue, stating that despite having the correct settings, the links to CSV files were not working for moderators and admins. pmusaraj requested the raw contents of the PM to investigate further.

T_Disco discovered that the issue was due to the CSV extension not being added to the authorized extensions for staff setting. After adding the extension, the CSV link in the PM worked. T_Disco suggested improvements to the automation pages and error handling to prevent similar issues.

joffreyjaffeux implemented a change to generate an error when saving an automation with attach_csv checked if csv is not in the list of authorized_extensions. This change was reported by T_Disco and agreed with by pmusaraj. The fix is available in a pull request. T_Disco thanked joffreyjaffeux for the update.

In the data explorer ‘Allow groups to access this query’ is set to: moderators, admins, staff

In the Automation record ‘Attach the CSV file to the PM’ is ticked. The script is ‘Schedule a PM with Data explorer results’.

The recipients are an admin and a moderator - same result for both.

I’ve tried it with a couple of data explorer queries, ‘Inactive Users with no posts’ for instance. (The csv is available to download on the Data explorer page.)

The Discourse version installed is 3.4.0.beta3-dev (d7503a6153), the Data Explorer plugin is up to date (f2891947).

Automation setting for the ‘Inactive Users with no posts’ PM:

1 Like

Can you share the raw contents of one of these PMs sent by the automation? Feel free to PM me if it’s content not meant for a public audience.

This was due to the csv extension not being added to the authorized extensions for staff setting.

After adding the csv extension and retriggering a PM the csv link in the subsequent PM worked.

A couple of suggestions:

  1. On the automation pages, add some text and a link after the tickbox ‘Attach the CSV file to the PM’. Something like: (Requires authorization of csv extension). Linking ‘authorization of csv extension’ to /admin/site_settings/category/all_results?filter=authorized%20extensions%20for%20staff

  2. To help diagnose what the issue is in future instances, if possible, change the link in the PM when csv isn’t an authorized extension, from:
    href=“/404”
    to something like:
    href=“/unauthorized”

Thanks @pmusaraj for helping me with this one! :heart:

1 Like

Thank you for tracking it down to that site setting! It’s a sneaky one!

1 Like

I can’t do all your recommendations but from now when you save an automation using this script and attach_csv is checked, it will generate an error if csv is not in the list of authorized_extensions:

Screenshot 2024-12-09 at 17.09.14

https://github.com/discourse/discourse-data-explorer/pull/346

Thanks for the report.

2 Likes

That’s great, thank you @j.jaffeux !

1 Like