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

Initialise Headers map to avoid runtime panic when purging. #267

Merged
merged 3 commits into from
Mar 25, 2021

Conversation

Integralist
Copy link
Collaborator

Problem: #266

The call to new(RequestOptions) initialises the struct with zero values. So the RequestOptions.Headers map is nil by default . Hence trying to assign a value to nil results in panic: assignment to entry in nil map:

Example code that validated this:

p, err := client.Purge(&fastly.PurgeInput{
	URL:  "http://testing-gofastly-purge.integralist-test.com.global.prod.fastly.net/anything/foo",
	Soft: true,
})

@Integralist Integralist requested review from phamann, a team and kailan and removed request for a team March 25, 2021 14:14
Copy link
Member

@kailan kailan left a comment

Choose a reason for hiding this comment

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

Looks good 👍

@Integralist Integralist force-pushed the integralist/20210335_purge_panic branch from ff4718c to 121839d Compare March 25, 2021 14:18
fastly/purge.go Outdated Show resolved Hide resolved
@Integralist Integralist merged commit 59b80a5 into master Mar 25, 2021
@Integralist Integralist deleted the integralist/20210335_purge_panic branch March 25, 2021 16:34
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