Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

invalid memory address or nil pointer dereference when SOURCE_SECRET_SEED is empty in config #1

Closed
nikhilsaraf opened this issue Aug 24, 2018 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@nikhilsaraf
Copy link
Contributor

Describe the bug

The bot crashes on startup when trying to print the config details if you don't include the SOURCE_SECRET_SEED in the trader config file.

I think this behavior is incorrect because the account setup walkthrough and sample config file says that the SOURCE_SECRET_SEED is optional.

Here is the log of the error:

2018/08/24 14:41:14 Starting Kelp Trader: v1.0.0-rc1 [337f478b0e7a1dc235aef31788754bc1ab11b6a1]
2018/08/24 14:41:14 configs:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1358134]

goroutine 1 [running]:
github.com/lightyeario/kelp/support/utils.SecretKey2PublicKey(0x140ddc0, 0xc42025ea50, 0x98, 0x140ddc0)
	~/dev/go/src/github.com/lightyeario/kelp/support/utils/configs.go:62 +0xd4
github.com/lightyeario/kelp/support/utils.StructString(0x14a9740, 0xc42025ea50, 0xc4201e5450, 0xc42025ea50, 0xc4201e5510)
	~/dev/go/src/github.com/lightyeario/kelp/support/utils/configs.go:40 +0x2b2
github.com/lightyeario/kelp/trader.BotConfig.String(0x0, 0x0, 0xc4201bd040, 0x38, 0xc4201c0f60, 0x3, 0x0, 0x0, 0xc4201c0f80, 0x6, ...)
	~/dev/go/src/github.com/lightyeario/kelp/trader/config.go:32 +0x180
github.com/lightyeario/kelp/support/utils.CheckConfigError(0x151d0c0, 0xc42025e960, 0x0, 0x0, 0x7fff5fbff52c, 0x11)
	~/dev/go/src/github.com/lightyeario/kelp/support/utils/configs.go:20 +0x198
github.com/lightyeario/kelp/cmd.init.4.func1(0x175f680, 0xc420081440, 0x0, 0x6)
	~/dev/go/src/github.com/lightyeario/kelp/cmd/trade.go:65 +0x287
github.com/lightyeario/kelp/vendor/github.com/spf13/cobra.(*Command).execute(0x175f680, 0xc4200813e0, 0x6, 0x6, 0x175f680, 0xc4200813e0)
	~/dev/go/src/github.com/lightyeario/kelp/vendor/github.com/spf13/cobra/command.go:702 +0x2c6
github.com/lightyeario/kelp/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x175fce0, 0x1005d9c, 0xc42002c118, 0x0)
	~/dev/go/src/github.com/lightyeario/kelp/vendor/github.com/spf13/cobra/command.go:783 +0x2e4
github.com/lightyeario/kelp/vendor/github.com/spf13/cobra.(*Command).Execute(0x175fce0, 0x0, 0x13becf2)
	~/dev/go/src/github.com/lightyeario/kelp/vendor/github.com/spf13/cobra/command.go:736 +0x2b
main.main()
	~/dev/go/src/github.com/lightyeario/kelp/main.go:10 +0x2d

Expected behavior

I think the correct behavior in this situation is for the bot to not crash if SOURCE_SECRET_SEED is missing or empty. The value printed out to the display can always be an empty value in this case.

Frequency

The frequency is: Always

Steps To Reproduce

Here are the steps to reproduce the issue (see attachments in section below):

  1. Set up your configuration file with the SOURCE_SECRET_SEED field to be empty
  2. Start the bot using this command:
    ./kelp trade -c sample_trader.cfg -s buysell -f sample_buysell.cfg --sim
  3. The bot will crash with the error mentioned above.

Possible Solution

This bug can be fixed by allowing an empty value for the secret key when printing the config.

Your Environment

version: v1.0.0-rc1
git hash: 337f478b0e7a1dc235aef31788754bc1ab11b6a1
build date: 20180813T231816Z
GOOS: linux
GOARCH: amd64

Context

I am unable to use the same account as the trader account and the source account because of this bug. As a workaround, I'm currently copy-pasting the value in the TRADER_SECRET_SEED for the SOURCE_SECRET_SEED, although I know that's not the intended usage.

Attachments

No relevant attachments

@nikhilsaraf nikhilsaraf added the bug Something isn't working label Aug 24, 2018
@nikhilsaraf nikhilsaraf added this to the v1.0.0-rc2 milestone Aug 26, 2018
@nikhilsaraf nikhilsaraf modified the milestones: v1.0.0-rc3, v1.0.0-rc2 Sep 28, 2018
nikhilsaraf pushed a commit to nikhilsaraf/kelp that referenced this issue Oct 24, 2018
* Add PagerDuty code

* Adding files

* remove test file

* go fmt

* Address PR comments

* Add new files

* remove api key

* Add comments

* move function around

* Fix tests

* Add pagerduty test for details

* json marshal test detail struct

* Edit comment

* Pointer receiver

* Address PR comments
nikhilsaraf pushed a commit that referenced this issue Oct 29, 2018
* Update trade.go

* Update trade.go

* Update trade.go
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant