-
Notifications
You must be signed in to change notification settings - Fork 8.6k
FIX: Check tag group names in form template validator #33850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The previous form template validator did not detect non-existent tag group names, which would result in the page being saved normally when an incorrect name was entered, but causing the interface to crash during preview and a 500 error to be thrown when the user used it. This commit adds detection for non-existent tag group names and fixes this issue
This pull request has been mentioned on Discourse Meta. There might be relevant details there: https://meta.discourse.org/t/form-templates-preview-broken-with-tag-group/372744/3 |
@@ -31,6 +31,8 @@ def validate(record) | |||
check_ids(record, field, existing_ids) | |||
check_descriptions_html(record, field) | |||
end | |||
|
|||
check_tag_groups(record, yaml.map { |f| f["tag_group"] }.compact.map(&:downcase).uniq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check_tag_groups(record, yaml.map { |f| f["tag_group"] }.compact.map(&:downcase).uniq) | |
check_tag_groups(record, yaml.map { |f| f["tag_group"] }) |
I feel like .compact.map(&:downcase).uniq
should be done in check_tag_groups
. Otherwise, it isn't clear that the tag_group_names
argument expects an array of tag group names that have been compacted and downcased.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea! resolved this.
Should we also prevent this? Otherwise, existing site with invalid values will still encounter a 500 error. |
This pull request has been mentioned on Discourse Meta. There might be relevant details there: https://meta.discourse.org/t/daily-summary-9pm-utc/291850/579 |
The previous form template validator did not detect non-existent tag group names, which would result in the page being saved normally when an incorrect name was entered, but causing the interface to crash during preview and a 500 error to be thrown when the user used it.
This commit adds detection for non-existent tag group names and fixes this issue