Project

General

Profile

Unable to upload images bigger than 100KB with redminex-ckeditor

Added by Sergio Tadini 13 days ago

Hello
I have a problem uploading images with redminex-ckeditor plugin.
I've installed the 1.2.4 release of the plugin and changed plugins/redmine_ckeditor/rich/lib/rich/url_generator.rb to correcly render images with spaces or special characters (thanks to https://www.redmine.org/issues/38968).

The only problem that remains is that I cannot upload images larger than 100KB.
With smaller images everything works as expected.
With a larger image it fails showing a red x thumbnail (and error 500 in log).
I've changed the plugin code in file plugins/redmine_ckeditor/rich/app/controllers/rich/files_controller.rb to get some more info in log. The change is:

      file_params = params[:file] || params[:qqfile]
      if(file_params)
        file_params.content_type = Mime::Type.lookup_by_extension(file_params.original_filename.split('.').last.to_sym)
        logger.error("Size property for the file: #{file_params.size}")
        begin
          @file.rich_file = file_params
        rescue => e
          logger.error("Error assigning params to file: #{e.message}")
          logger.error(e.backtrace.join("\n"))
        end
      end

When I try to upload a "big" image, the log shows:

E, [2024-06-17T13:17:53.639912 #20008] ERROR -- : [2f3290d9-311e-412c-86f7-d4f605a1f3b2] Size property for the file: 143513
E, [2024-06-17T13:17:53.640054 #20008] ERROR -- : [2f3290d9-311e-412c-86f7-d4f605a1f3b2] Error assigning params to file: no implicit conversion of nil into String
E, [2024-06-17T13:17:53.640254 #20008] ERROR -- : [2f3290d9-311e-412c-86f7-d4f605a1f3b2] /usr/share/gems/gems/paperclip-6.1.0/lib/paperclip/io_adapters/uploaded_file_adapter.rb:29:in `size'
/usr/share/gems/gems/paperclip-6.1.0/lib/paperclip/io_adapters/uploaded_file_adapter.rb:29:in `cache_current_values'
/usr/share/gems/gems/paperclip-6.1.0/lib/paperclip/io_adapters/uploaded_file_adapter.rb:11:in `initialize'
/usr/share/gems/gems/paperclip-6.1.0/lib/paperclip/io_adapters/registry.rb:33:in `new'
/usr/share/gems/gems/paperclip-6.1.0/lib/paperclip/io_adapters/registry.rb:33:in `for'
/usr/share/gems/gems/paperclip-6.1.0/lib/paperclip/attachment.rb:100:in `assign'
/usr/share/gems/gems/paperclip-6.1.0/lib/paperclip/has_attached_file.rb:66:in `block in define_setter'
/var/www/redmine/plugins/redmine_ckeditor/rich/app/controllers/rich/files_controller.rb:57:in `create'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/abstract_controller/base.rb:228:in `process_action'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal/rendering.rb:30:in `process_action'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
/usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/callbacks.rb:117:in `block in run_callbacks'
/var/www/redmine/lib/redmine/sudo_mode.rb:61:in `sudo_mode'
/usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/callbacks.rb:126:in `block in run_callbacks'
/usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/callbacks.rb:137:in `run_callbacks'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/abstract_controller/callbacks.rb:41:in `process_action'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal/rescue.rb:22:in `process_action'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
/usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/notifications.rb:203:in `block in instrument'
/usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/notifications.rb:203:in `instrument'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal/instrumentation.rb:33:in `process_action'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
/usr/share/gems/gems/activerecord-6.1.7.8/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/abstract_controller/base.rb:165:in `process'
/usr/share/gems/gems/actionview-6.1.7.8/lib/action_view/rendering.rb:39:in `process'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal.rb:190:in `dispatch'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_controller/metal.rb:254:in `dispatch'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/routing/route_set.rb:33:in `serve'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/journey/router.rb:50:in `block in serve'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/journey/router.rb:32:in `each'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/journey/router.rb:32:in `serve'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/routing/route_set.rb:842:in `call'
/usr/share/gems/gems/railties-6.1.7.8/lib/rails/engine.rb:539:in `call'
/usr/share/gems/gems/railties-6.1.7.8/lib/rails/railtie.rb:207:in `public_send'
/usr/share/gems/gems/railties-6.1.7.8/lib/rails/railtie.rb:207:in `method_missing'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/routing/mapper.rb:20:in `block in <class:Constraints>'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/routing/mapper.rb:49:in `serve'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/journey/router.rb:50:in `block in serve'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/journey/router.rb:32:in `each'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/journey/router.rb:32:in `serve'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/routing/route_set.rb:842:in `call'
/usr/share/gems/gems/rack-raw-upload-1.1.1/lib/rack/raw_upload.rb:72:in `convert_and_pass_on'
/usr/share/gems/gems/rack-raw-upload-1.1.1/lib/rack/raw_upload.rb:18:in `call'
/usr/share/gems/gems/rack-2.2.9/lib/rack/tempfile_reaper.rb:15:in `call'
/usr/share/gems/gems/rack-2.2.9/lib/rack/etag.rb:27:in `call'
/usr/share/gems/gems/rack-2.2.9/lib/rack/conditional_get.rb:40:in `call'
/usr/share/gems/gems/rack-2.2.9/lib/rack/head.rb:12:in `call'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/http/permissions_policy.rb:22:in `call'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/http/content_security_policy.rb:19:in `call'
/usr/share/gems/gems/rack-2.2.9/lib/rack/session/abstract/id.rb:266:in `context'
/usr/share/gems/gems/rack-2.2.9/lib/rack/session/abstract/id.rb:260:in `call'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/cookies.rb:697:in `call'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
/usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/callbacks.rb:98:in `run_callbacks'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
/usr/share/gems/gems/railties-6.1.7.8/lib/rails/rack/logger.rb:37:in `call_app'
/usr/share/gems/gems/railties-6.1.7.8/lib/rails/rack/logger.rb:26:in `block in call'
/usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/tagged_logging.rb:99:in `block in tagged'
/usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/tagged_logging.rb:37:in `tagged'
/usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/tagged_logging.rb:99:in `tagged'
/usr/share/gems/gems/railties-6.1.7.8/lib/rails/rack/logger.rb:26:in `call'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
/usr/share/gems/gems/request_store-1.5.1/lib/request_store/middleware.rb:19:in `call'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/request_id.rb:26:in `call'
/usr/share/gems/gems/rack-2.2.9/lib/rack/method_override.rb:24:in `call'
/usr/share/gems/gems/rack-2.2.9/lib/rack/runtime.rb:22:in `call'
/usr/share/gems/gems/activesupport-6.1.7.8/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/executor.rb:14:in `call'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/static.rb:24:in `call'
/usr/share/gems/gems/rack-2.2.9/lib/rack/sendfile.rb:110:in `call'
/usr/share/gems/gems/rack-2.2.9/lib/rack/content_length.rb:17:in `call'
/usr/share/gems/gems/actionpack-6.1.7.8/lib/action_dispatch/middleware/host_authorization.rb:142:in `call'
/usr/share/gems/gems/railties-6.1.7.8/lib/rails/engine.rb:539:in `call'
/usr/share/gems/gems/puma-6.4.2/lib/puma/configuration.rb:272:in `call'
/usr/share/gems/gems/puma-6.4.2/lib/puma/request.rb:100:in `block in handle_request'
/usr/share/gems/gems/puma-6.4.2/lib/puma/thread_pool.rb:378:in `with_force_shutdown'
/usr/share/gems/gems/puma-6.4.2/lib/puma/request.rb:99:in `handle_request'
/usr/share/gems/gems/puma-6.4.2/lib/puma/server.rb:464:in `process_client'
/usr/share/gems/gems/puma-6.4.2/lib/puma/server.rb:245:in `block in run'
/usr/share/gems/gems/puma-6.4.2/lib/puma/thread_pool.rb:155:in `block in spawn_thread'
I, [2024-06-17T13:17:53.640957 #20008]  INFO -- : [2f3290d9-311e-412c-86f7-d4f605a1f3b2] Completed 500 Internal Server Error in 5ms (ActiveRecord: 0.8ms | Allocations: 1605)
F, [2024-06-17T13:17:53.641671 #20008] FATAL -- : [2f3290d9-311e-412c-86f7-d4f605a1f3b2]
[2f3290d9-311e-412c-86f7-d4f605a1f3b2] ArgumentError (wrong number of arguments (given 3, expected 1..2)):
[2f3290d9-311e-412c-86f7-d4f605a1f3b2]
[2f3290d9-311e-412c-86f7-d4f605a1f3b2] plugins/redmine_ckeditor/rich/app/controllers/rich/files_controller.rb:64:in `create'

I'm out of ideas about how to fix this issue.
The server is a test one running with puma and nothing in front of it. As per what I've found, puma shouldn't have any limit in the upload file size nor I have any custom parameter in the redmine config.
This is a restore/upgrade on a new server coming from a 4.0 release running on a old machine that will be dismissed shortly.

Here is my environment details (about output):


Environment:
  Redmine version                5.1.3.stable
  Ruby version                   3.0.7-p220 (2024-04-23) [x86_64-linux]
  Rails version                  6.1.7.8
  Environment                    production
  Database adapter               Mysql2
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                smtp
Redmine settings:
  Redmine theme                  Default
SCM:
  Git                            2.43.0
  Filesystem
Redmine plugins:
  redmine_ckeditor               1.2.4


Can someone help me?

Thank you