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

pass correct client to patchWithAgent in newAppClient #77

Merged
merged 1 commit into from
Jun 17, 2020
Merged

pass correct client to patchWithAgent in newAppClient #77

merged 1 commit into from
Jun 17, 2020

Conversation

michaelshobbs
Copy link
Contributor

i ran into the following panic in master when passing a custom http client in BotConfig. looks like it was a minor oversight in the call to patchWithAgent in newAppClient.

panic:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xe124f6]

goroutine 1 [running]:
panic(0x14579c0, 0x24f43b0)
	/usr/local/go/src/runtime/panic.go:969 +0x166
github.com/turnage/graw/reddit.patchWithAgent(...)
	/app/vendor/github.com/turnage/graw/reddit/agentforwarder.go:21
github.com/turnage/graw/reddit.newAppClient(0x1665af7, 0xe, 0xc0000400ee, 0xe, 0xc000042102, 0x1b, 0x0, 0x0, 0x0, 0x0, ...)
	/app/vendor/github.com/turnage/graw/reddit/appclient.go:82 +0x46
github.com/turnage/graw/reddit.newClient(0x1665af7, 0xe, 0xc0000400ee, 0xe, 0xc000042102, 0x1b, 0x0, 0x0, 0x0, 0x0, ...)
	/app/vendor/github.com/turnage/graw/reddit/client.go:82 +0x2fb
github.com/turnage/graw/reddit.NewBot(0x1665af7, 0xe, 0xc0000400ee, 0xe, 0xc000042102, 0x1b, 0x0, 0x0, 0x0, 0x0, ...)
	/app/vendor/github.com/turnage/graw/reddit/bot.go:41 +0xe4

example code to reproduce:

	client := &http.Client{
		Transport: &http.Transport{
			IdleConnTimeout:     defaultIdleConnTimeout,
			MaxIdleConnsPerHost: maxConnections,
		},
		Timeout: timeout,
	}

	bot, err := reddit.NewBot(reddit.BotConfig{
		Agent:  agent,
		Rate:   time.Second * 1,
		Client: client,
		App: reddit.App{
			ID:     config.Reddit.API.ID,
			Secret: config.Reddit.API.Secret,
		},
	})

@CLAassistant
Copy link

CLAassistant commented Jun 17, 2020

CLA assistant check
All committers have signed the CLA.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 4.071% when pulling 53c55c6 on michaelshobbs:fix/new-app-client-patch-with-agent into 65715ee on turnage:master.

@turnage turnage merged commit 4c520bf into turnage:master Jun 17, 2020
@turnage
Copy link
Owner

turnage commented Jun 17, 2020

Thank you for submitting a pull request!

@michaelshobbs michaelshobbs deleted the fix/new-app-client-patch-with-agent branch June 17, 2020 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants