-
Notifications
You must be signed in to change notification settings - Fork 4
Adding _default: to a config library breaks configurations if other config library _definitions...: appear below it #521
Description
The error:
#<ActionView::Template::Error: Prevented a bad configuration of OptionConfigs::ActivityLogOptions in ActivityLog (Project). update_reference_ref_status is not recognized as a valid attribute.>
/var/app/current/app/models/option_configs/extra_options.rb:583:in 'OptionConfigs::ExtraOptions.parse_config'
/var/app/current/app/models/dynamic/def_handler.rb:368:in 'Dynamic::DefHandler#option_configs'
/var/app/current/app/views/admin/activity_logs/_def_details.html.erb:44:in '_app_views_admin_activity_logs__def_details_html_erb___127748801436879853_190520'
/var/app/current/app/views/admin/activity_logs/_form_info.html.erb:15:in '_app_views_admin_activity_logs__form_info_html_erb___269211580789647524_190512'
/var/app/current/app/views/admin/activity_logs/form/_info_block.html.erb:3:in '_app_views_admin_activity_logs_form__info_block_html_erb___4525610682413652423_190504'
/var/app/current/app/views/admin/activity_logs/_form.html.erb:21:in '_app_views_admin_activity_logs__form_html_erb__1597444935583095366_190472'
/var/app/current/app/controllers/concerns/admin_controller_handler.rb:58:in 'AdminControllerHandler#edit'
update_reference_ref_status appears in this part of the extra options config:
_definitions:
fs_enabled_if: &enabled_if
always: true
# @library common filestore_container
# @library projects email_definitions
# @library projects field_options
########
update_reference_ref_status: &update_reference_ref_status
force_not_editable_save: true
first:
top_referring_record:
update: return_result
The root cause of this is as the title says. Basically, after substitution of the config library, we get the equivalent of this configuration:
_definitions:
fs_enabled_if: &enabled_if
always: true
#### @library common filestore_container
#### @library projects email_definitions
#### @library projects field_options
_definitions_field_options:
never: &never
never: true
_default:
show_if:
a_field: *never
########
update_reference_ref_status: &update_reference_ref_status
force_not_editable_save: true
first:
top_referring_record:
update: return_result
Basically, the _default: is never closed and the following lines continue as if they were part of it, rather than the original definition.
Possible options:
- warn if
_definitions...:and_default:collide, based on a regex of the text before parsing - close all config libraries with a closing
_definitions_close_...:tag - just accept that this is bad practice!
The side effect is that an affected activity log can't be edited, since
OptionConfigs::ExtraOptions.all_option_configs_notices(object_instance.option_configs)
raises an exception in object_instance..option_configs. The exception is valid, since there was a failure to parse the YAML.
One option is to add an extra option to option_configs as no_parse_exceptions, to at least allow the item to be edited and corrected. Or to pass just object_instance so that we can rescue the error within all_option_configs_notices