thecartercenter / nemo

NEMO is a mobile data collection and analysis web application.
https://getnemo.org
Apache License 2.0
60 stars 63 forks source link

Editing a paused live form and adding an existing questions results in a application crash #914

Open thinqdeliver opened 2 years ago

thinqdeliver commented 2 years ago

Error message:

An ActiveRecord::RecordNotUnique occurred in forms#add_questions:

PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_form_items_on_form_id_and_question_id" DETAIL: Key (form_id, question_id)=(d31b51ad-30ac-470c-bda5-0e0f08ecadde, 238180dc-0bff-4435-8e5f-467ce3ba70be) already exists.

app/models/form.rb:145:in `block in add_questions_to_top_level'


Backtrace:

app/models/form.rb:145:in block in add_questions_to_top_level' app/models/form.rb:141:ineach' app/models/form.rb:141:in each_with_index' app/models/form.rb:141:inadd_questions_to_top_level' app/controllers/forms_controller.rb:202:in add_questions' app/models/setting.rb:68:inwith_cache' app/controllers/concerns/application_controller/caching.rb:12:in `enable_settings_caching'