ChiliProject is not maintained anymore. Please be advised that there will be no more updates.

We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.

Document Upload Failure (500 Internal Server Error) - Any ideas?

Added by Chuck M at 2012-04-16 01:28 pm

I have a fairly fresh installation of Chiliproject 3.1. I am able to add an issue (uploading a file attachment works). However, trying to upload a document in the documents area results in the error below in the log files (and an error to the web user in the browser). It appears that the file does in fact successfully upload and is there. Does anyone have any ideas as to what might be wrong?

===========ERROR BELOW==============
Processing DocumentsController#add_attachment (for 192.168.1.100 at 2012-04-16 09:08:38) [POST]
Parameters: {"authenticity_token"=>"GKhRg6NVpCzUMjyZLSHEx054tqLBkmmxg04+So7uA1k=", "attachments"=>{"1"=>{"file"=>#<File:C:/Windows/Temp/RackMultipart20120416-1672-5cvzn2>, "description"=>""}}, "commit"=>"Add", "controller"=>"documents", "action"=>"add_attachment", "id"=>"1"}

NoMethodError (undefined method `container' for #<Array:0x5ed9700>):
app/controllers/documents_controller.rb:88:in `add_attachment'
<internal:prelude>:10:in `synchronize'
thin (1.3.1) lib/thin/connection.rb:80:in `block in pre_process'
thin (1.3.1) lib/thin/connection.rb:78:in `catch'
thin (1.3.1) lib/thin/connection.rb:78:in `pre_process'
thin (1.3.1) lib/thin/connection.rb:53:in `process'
thin (1.3.1) lib/thin/connection.rb:38:in `receive_data'
C:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4.1-x86-mingw32/lib/eventmachine.rb:179:in `run_machine'
C:/Ruby/Ruby193/lib/ruby/gems/1.9.1/gems/eventmachine-1.0.0.beta.4.1-x86-mingw32/lib/eventmachine.rb:179:in `run'
thin (1.3.1) lib/thin/backends/base.rb:61:in `start'
thin (1.3.1) lib/thin/server.rb:159:in `start'
thin (1.3.1) lib/thin/controllers/controller.rb:86:in `start'
thin (1.3.1) lib/thin/runner.rb:185:in `run_command'
thin (1.3.1) lib/thin/runner.rb:151:in `run!'
thin (1.3.1) bin/thin:6:in `<top (required)>'
C:/Ruby/Ruby193/bin/thin:19:in `load'
C:/Ruby/Ruby193/bin/thin:19:in `<main>'

Rendering C:/ChiliProject/chiliproject-3.1.0/public/500.html (500 Internal Server Error)


Replies (3)

RE: Document Upload Failure (500 Internal Server Error) - Any ideas? - Added by Felix Schäfer at 2012-04-19 11:53 am

Can you please test if the problem exists with 1.9.2 and/or other servers than thin (e.g. webrick or passenger)?

RE: Document Upload Failure (500 Internal Server Error) - Any ideas? - Added by Chuck M at 2012-04-19 01:09 pm

Thanks for the reply...

I started up the server using webrick via command prompt... bundle exec ruby script/server -p 80 -e production
Uploading the document was successful without error.

Starting the server using Thin via command prompt... C:\Ruby\Ruby193\bin\thin -c C:\ChiliProject\chiliproject-3.1.0 -p 80 -e production --prefix /myprojects start
Uploading the document was successful without error.

Starting the server using Thin via windows services (with local system account)... C:\Ruby\Ruby193\bin\thin -c C:\ChiliProject\chiliproject-3.1.0 -p 80 -e production --prefix /myprojects start
Uploading the document was successful without error.

I tried uploading files via the files section, was also successful without errors.

I have NO clue what has changed since 3 days ago and now, I don't think anything in terms of the services starting, etc... or the permissions. It has fixed itself. I will keep an eye on this and report back if it happens again.

RE: Document Upload Failure (500 Internal Server Error) - Any ideas? - Added by Mark G. at 2012-04-20 02:47 am

I have the same error.

Processing DocumentsController#add_attachment (for IP at 2012-04-19 21:26:24) [POST]
  Parameters: {"commit"=>"Add", "action"=>"add_attachment", "authenticity_token"=>"qS/Ge3fpwCILdfgdgdgnzakMoT/xDtU=", "id"=>"931", "controller"=>"documents", "attachments"=>{"1"=>{"file"=>#<File:/tmp/RackMultipart20120419-15616-tmkzx6-0>, "description"=>""}}}

NoMethodError (undefined method `container' for [:unsaved, []]:Array):
  app/controllers/documents_controller.rb:88:in `add_attachment'
  /home/redmine/rubystack/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
  /home/redmine/rubystack/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/lib/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request'
  /home/redmine/rubystack/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
  /home/redmine/rubystack/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/lib/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler'
  /home/redmine/rubystack/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/lib/phusion_passenger/classic_rails/application_spawner.rb:99:in `spawn_application'
  /home/redmine/rubystack/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/lib/phusion_passenger/utils.rb:479:in `safe_fork'
  /home/redmine/rubystack/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/lib/phusion_passenger/classic_rails/application_spawner.rb:84:in `spawn_application'
  /home/redmine/rubystack/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:230:in `spawn_rails_application'
  /home/redmine/rubystack/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:132:in `spawn_application'
  /home/redmine/rubystack/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/lib/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application'
  /home/redmine/rubystack/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:357:in `__send__'
  /home/redmine/rubystack/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
  /home/redmine/rubystack/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
  /home/redmine/rubystack/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.11/helper-scripts/passenger-spawn-server:99

Rendering /home/redmine/rubystack-2.3.14/apps/chiliproject-3.0.0/public/500.html (500 Internal Server Error)

I stuck this code into document_controller.rb to get around the problem.
It may or may not be correct, but it seems functional (and does mail the
watchers).

  def add_attachment
    attachments = Attachment.attach_files(@document, params[:attachments])
    render_attachment_warning_if_needed(@document)

    # This begin-rescue block is used to catch the following error:
    ## NoMethodError (undefined method `container' for [:unsaved, []]:Array):
    ##  app/controllers/documents_controller.rb:88:in `add_attachment'
    #
    # For whatever reason, the attachments.first.container object doesn't exist.
    # attachments.first is an array keyed by :unsaved, which is empty.
    begin
      if attachments.present? && attachments[:files].present? && Setting.notified_events.include?('document_added')
        # TODO: refactor
        #logger.error "before first. " << attachments.first.inspect
        #logger.error "before first. " << attachments.inspect
        #logger.error "before first. " << attachments.methods.to_s
        #logger.error "before first. " << attachments[:files].first.inspect
        attachments[:files].first.container.recipients.each do |recipient|
          Mailer.deliver_attachments_added(attachments[:files], recipient)
        end
      end
    rescue Exception => exception
      logger.error exception.inspect
      logger.error "Failed to notify attachment recipients for document: " << @document.title
    end
    redirect_to :action => 'show', :id => @document
  end

The problem is that attachments has two keyed elements, :unsaved
and :files. Using .first on attachments randomly returns either
:unsaved or :files. :unsaved is an empty list in this case.
:files is a list containing a single file.

I don't know how the original code was intended to work, but
the above seems to suffice.

(1-3/3)