-
Notifications
You must be signed in to change notification settings - Fork 636
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
Fixed crash in Page Rules update when using custom cache key #894
Conversation
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.
LGTM with a couple of non-blocking questions
func TestCacheKeyFieldsNilValue(t *testing.T) { | ||
pageRuleAction, err := transformToCloudflarePageRuleAction( | ||
"cache_key_fields", | ||
[]interface{}{map[string]interface{}{"cookie": []interface{}{map[string]interface{}{"check_presence": []interface{}{}, "include": []interface{}{"next-i18next"}}}, "header": []interface{}{map[string]interface{}{"check_presence": []interface{}{}, "exclude": []interface{}{}, "include": []interface{}{"x-forwarded-host"}}}, "host": []interface{}{map[string]interface{}{"resolved": false}}, "query_string": []interface{}{interface{}(nil)}, "user": []interface{}{map[string]interface{}{"device_type": true, "geo": true, "lang": true}}}}, |
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.
types, amirite? 😅
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.
This is the exact setting that triggers crash for the used who reported it. Put here as a regression test.
@@ -866,18 +866,23 @@ func transformToCloudflarePageRuleAction(id string, value interface{}, d *schema | |||
for sectionID, sectionValue := range cacheKeyActionSchema[0].(map[string]interface{}) { | |||
sectionOutput := map[string]interface{}{} | |||
|
|||
for fieldID, fieldValue := range sectionValue.([]interface{})[0].(map[string]interface{}) { | |||
sectionOutput[fieldID] = fieldValue | |||
if sectionValue.([]interface{})[0] != nil { |
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.
just checking ""
and 0
aren't possible here either?
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.
I think they shouldn't.
This PR fixes a crash that occurs when the existing Page Rule that did not have
custom_cache_key
is updated to have one.