Skip to content
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

Fix panic caused by incorrect type assert. #377

Merged
merged 2 commits into from
Mar 5, 2021

Conversation

Integralist
Copy link
Collaborator

@Integralist Integralist commented Mar 5, 2021

Problem: the gzip resource was recently migrated to using the DiffSet algorithm for determining changes, which introduced a bug where we incorrectly were type asserting a Set into a String which would cause a panic at runtime.

Notes: the tests didn't catch this because the pre-existing gzip tests were written in such a way that the 'update' test was actually causing the gzip resource to be deleted and recreated anew (because it was modifying the 'name' field) and so I've modified the tests to address this.

@Integralist Integralist requested review from a team, phamann and kailan and removed request for a team March 5, 2021 15:40
@Integralist Integralist added the bug label Mar 5, 2021
Copy link
Member

@phamann phamann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻 LGTM

for _, elem := range set.List() {
s = append(s, elem.(string))
}
opts.ContentTypes = gofastly.String(strings.Join(s, " "))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting here for reviewers, this API accepts the types as a space-seperated list, so this is correct 👍
https://developer.fastly.com/reference/api/vcl-services/gzip/

name = "amazon docs"
}

gzip {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to clarify why this new test validates the actual 'update' mechanics...

The original test thought it was validating a 'modification' to the gzip resource, but because they changed the name field (along with other fields) it meant that the gzip resource was actually being 'deleted' and then 'recreated' so the 'modification' logic (which is where the panic happens) was never actually run.

To ensure the modification/update logic is executed I created a new test that updated the gzip resource but left the name the same and just modified some of the other fields.

@Integralist Integralist merged commit db5f1bf into master Mar 5, 2021
@Integralist Integralist deleted the integralist/20210305_panic_typeset branch March 5, 2021 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants