Wrong number of fields in CSV export of users

AI-generated summary

A bug was reported in the CSV export of users feature, where the exporter omits commas when the last fields have no value, causing the file to be rejected by many tools. alranel encountered this issue and reported it. simon was able to reproduce the problem, which occurred when no group_names field was set for a user. The issue has since been fixed via a commit and assigned by the team, with sam acknowledging the fix and techAPJ implementing the solution.

I exported users in CSV format with the Admin > Users > Export button. While the file is substantially valid, it’s rejected by many tools (like miller or parsing libraries) because not all lines have the same number of commas/fields. It looks like your exporter omits commas when last fields have no value. While this looks reasonable, it looks like it breaks the formal specification of CSV files.

Discourse version: the one used as of now in your hosted forums :slight_smile:

3 Likes

That sounds like a bug. I’m assuming the issue with the users CSV file is happening when no group_names field is set for a user. I can reproduce that with a CSV file that contains staged users. Is this where you are seeing the problem?

Sorry for the big delay here, we will see if we can amend it so we include the right number of commas. We have this assigned out.

2 Likes

Fixed via

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

Thanks for reporting this issue @alranel :+1:

3 Likes

This topic was automatically closed after 16 hours. New replies are no longer allowed.