masweetman / export_docx

Export Redmine issues to docx files
14 stars 6 forks source link

Unable to upload template #19

Open BadMisterFrosty opened 6 years ago

BadMisterFrosty commented 6 years ago

I am having trouble uploading a template. It appears that the program is having trouble getting sudo. I have confirmed that the redmine user (that passenger runs redmine as) is able to sudo. In the logs below, you can see slightly different errors for "Add new" and "Replace Existing" options. Any ideas?

Note: Upon further investigation, this appears to only be happening with custom issues. I was able to successfully upload a template for a "Bug". Maybe there is a problem with the following line.

tracker = Tracker.find_by_name(params[:tracker])

Note 2: More investigation showed that this only affects Trackers that have a space in their names. e.g. "Action Item" vs "Bugs". Does the find_by_name parameter need to be quoted or something? I confirmed this by renaming "Action Item" to "ActionItem" and it appears to be working now.

Machine info

OS: Ubuntu 16.04.04 Apache 2.4.18 Passenger - 5.0.27 MySQL - 5.7.23

LogFile

Started POST "/settings/plugin/export_docx/upload" for 10.4.40.242 at 2018-08-16 13:58:46 -0400
Processing by DocxController#template_upload as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"1958JPbc1KTSdKurnz816aIKrBbj+pMpUzKp4K8VDva9h1DH5K/gNAv8bIhvjsRR9wmMavqN3wM01XQQlvh+Tw==", "tracker"=>"Action Item", "template_action"=>"Add new template", "use_for_all"=>"1", "commit"=>"Upload"}
  Current user: brose (id=4)
Completed 500 Internal Server Error in 15ms (ActiveRecord: 4.5ms)

NoMethodError (undefined method `original_filename' for nil:NilClass):
  plugins/export_docx/app/helpers/docx_helper.rb:26:in `upload_file'
  plugins/export_docx/app/controllers/docx_controller.rb:17:in `template_upload'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'

Started POST "/settings/plugin/export_docx/upload" for 10.4.40.242 at 2018-08-16 13:59:01 -0400
Processing by DocxController#template_upload as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"1958JPbc1KTSdKurnz816aIKrBbj+pMpUzKp4K8VDva9h1DH5K/gNAv8bIhvjsRR9wmMavqN3wM01XQQlvh+Tw==", "tracker"=>"Action Item", "template"=>#<ActionDispatch::Http::UploadedFile:0x00007f6acf1e0938 @tempfile=#<Tempfile:/tmp/RackMultipart20180816-6721-106vfiy.docx>, @original_filename="ai-templ.docx", @content_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document", @headers="Content-Disposition: form-data; name=\"template\"; filename=\"ai-templ.docx\"\r\nContent-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document\r\n">, "template_action"=>"Add new template", "use_for_all"=>"1", "commit"=>"Upload"}
  Current user: brose (id=4)
Completed 500 Internal Server Error in 16ms (ActiveRecord: 4.5ms)

TypeError (no implicit conversion of nil into String):
  plugins/export_docx/app/controllers/docx_controller.rb:29:in `block in template_upload'
  plugins/export_docx/app/controllers/docx_controller.rb:21:in `template_upload'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'
zion2k commented 5 years ago

I have the same issue.

KenyeresPeter commented 3 years ago

Fixed the issue in the following pull request: https://github.com/masweetman/export_docx/pull/21