stimulusreflex / stimulus_reflex

Build reactive applications with the Rails tooling you already know and love.
https://docs.stimulusreflex.com
MIT License
2.29k stars 176 forks source link

Form parse errors are not captured and reported back to front-end #682

Open dacook opened 9 months ago

dacook commented 9 months ago

Bug Report

Describe the bug

During development, I encountered an error (see stack trace below), but this did not result in the lifecycle event reflexError. Instead I was left watching a loading screen while nothing happened.

To Reproduce

Attempting to create a multi-record form with blank ID value, eg:

<input autocomplete="off" type="hidden" name="[products][0][variants_attributes][][name]" value="">

(I'm probably doing something wrong, but still the error should be caught).

Expected behavior

Lifecycle event reflexError being called.

Screenshots or reproduction

Example stack trace:

Reflex products#bulk_update failed: expected Array (got Rack::QueryParser::Params) for param `variants_attributes' [http://localhost:3000/admin/products]
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/query_parser.rb:113:in `normalize_params'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/query_parser.rb:122:in `normalize_params'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/query_parser.rb:122:in `normalize_params'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/query_parser.rb:75:in `block in parse_nested_query'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/query_parser.rb:72:in `each'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/query_parser.rb:72:in `parse_nested_query'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/rack-2.2.8/lib/rack/utils.rb:113:in `parse_nested_query'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/stimulus_reflex-3.5.0.rc3/lib/stimulus_reflex/reflex_data.rb:51:in `form_data'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/stimulus_reflex-3.5.0.rc3/lib/stimulus_reflex/reflex_data.rb:59:in `form_params'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/stimulus_reflex-3.5.0.rc3/lib/stimulus_reflex/reflex_data.rb:55:in `params'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/stimulus_reflex-3.5.0.rc3/lib/stimulus_reflex/reflex_factory.rb:14:in `create_reflex_from_data'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/stimulus_reflex-3.5.0.rc3/app/channels/stimulus_reflex/channel.rb:19:in `receive'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/view_component_reflex-3.1.14.pre9/lib/view_component_reflex/engine.rb:30:in `receive'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/channel/base.rb:268:in `public_send'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/channel/base.rb:268:in `dispatch_action'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/channel/base.rb:170:in `block in perform_action'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/notifications.rb:206:in `block in instrument'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/notifications.rb:206:in `instrument'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/channel/base.rb:169:in `perform_action'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/connection/subscriptions.rb:56:in `perform_action'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/connection/subscriptions.rb:19:in `execute_command'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/connection/base.rb:89:in `dispatch_websocket_message'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/server/worker.rb:59:in `block in invoke'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/tagged_logging.rb:99:in `block in tagged'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/tagged_logging.rb:37:in `tagged'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/tagged_logging.rb:99:in `tagged'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/connection/tagged_logger_proxy.rb:24:in `tag'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/server/worker/active_record_connection_management.rb:16:in `with_database_connections'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:127:in `block in run_callbacks'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/engine.rb:71:in `block (4 levels) in <class:Engine>'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/execution_wrapper.rb:92:in `wrap'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/engine.rb:66:in `block (3 levels) in <class:Engine>'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:127:in `instance_exec'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:127:in `block in run_callbacks'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/activesupport-7.0.8/lib/active_support/callbacks.rb:138:in `run_callbacks'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/server/worker.rb:42:in `work'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/server/worker.rb:58:in `invoke'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/actioncable-7.0.8/lib/action_cable/server/worker.rb:53:in `block in async_invoke'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:359:in `run_task'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:350:in `block (3 levels) in create_worker'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:341:in `loop'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:341:in `block (2 levels) in create_worker'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:340:in `catch'
/Users/dcook/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/concurrent-ruby-1.2.3/lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:340:in `block in create_worker'

Versions

StimulusReflex

External tools

Browser