Users reported that the “Download My Posts” feature failed with the error “Data export failed” and a backtrace pointing to undefined method 'name' for nil:NilClass in export_csv_file.rb. moparisthebest confirmed the issue on Discourse v1.8.4 and later on v1.9.0.beta5 after upgrading to the tests-passed branch. The issue did not occur for newly created accounts, suggesting data corruption from an SMF import. codinghorror suspected the import was faulty. techAPJ could not reproduce the issue but later identified it as likely caused by an incorrect parent category ID. A fix was pushed to gracefully handle the error and allow exports to proceed (commit). moparisthebest confirmed the fix was already in tests-passed and successfully applied it via command line, restoring export functionality. They also asked whether the underlying parent category issue should be fixed, which remains open.
User informed me they could not download their posts, I tried as well (button in user/activity), I get a message saying “Data export failed” and this is in the logs:
Message
Job exception: undefined method `name' for nil:NilClass
Backtrace
/var/www/discourse/app/jobs/regular/export_csv_file.rb:226:in `get_user_archive_fields'
/var/www/discourse/app/jobs/regular/export_csv_file.rb:66:in `block in user_archive_export'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/relation/delegation.rb:46:in `each'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/relation/delegation.rb:46:in `each'
/var/www/discourse/app/jobs/regular/export_csv_file.rb:65:in `user_archive_export'
/var/www/discourse/app/jobs/regular/export_csv_file.rb:48:in `each'
/var/www/discourse/app/jobs/regular/export_csv_file.rb:48:in `block in execute'
/usr/local/lib/ruby/2.3.0/csv.rb:1282:in `open'
/var/www/discourse/app/jobs/regular/export_csv_file.rb:46:in `execute'
/var/www/discourse/app/jobs/base.rb:154:in `block (2 levels) in perform'
Env
hostname hetzner1-smf
process_id 1372
application_version ae8bd6c8258f729025656705545a45992fa82f9c
current_db default
current_hostname forum.moparisthebest.com
job Jobs::ExportCsvFile
problem_db default
opts null
entity user_archive
user_id 1
current_site_id default
I am on current discourse stable v1.8.4 installed the supported way through docker on ubuntu.
So the original reporting user made a new account, made a post, and export posts worked for that new account. My only thought is this forum and users were imported from an SMF forum using the included importer, did it not do something correctly?
The error you are seeing is most probably because of incorrect ID saved for a parent category. I just pushed a fix to handle the error and continue exporting archive.
Is there a way to pull just that commit into my discourse without changing the version from tests-passed to master? Alternatively, when will that be in tests-passed?