Shopify / themekit

Shopify theme development command line tool.
https://shopify.dev/tools/theme-kit
MIT License
1.2k stars 375 forks source link

Crash when checking response status code #790

Closed andyw8 closed 4 years ago

andyw8 commented 4 years ago

We received a crash report, seems that we need to check that resp is not null before we check _resp.StatusCode:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x145c8f2]
goroutine 78 [running]:
github.com/Shopify/themekit/src/httpify.(*HTTPClient).doWithRetry(0xc0002b2800, 0xc00016e000, 0x14ee800, 0xc0000a8c30, 0x1, 0xc00034a190, 0x0)
        /Users/andyw8/src/github.com/Shopify/themekit/src/httpify/client.go:130 +0x102
github.com/Shopify/themekit/src/httpify.(*HTTPClient).do(0xc0002b2800, 0x15775a6, 0x3, 0xc0002cba00, 0x33, 0x14ee800, 0xc0000a8c30, 0xc0000a8c00, 0x100cead, 0x1556e60, ...)
        /Users/andyw8/src/github.com/Shopify/themekit/src/httpify/client.go:105 +0x5d1
github.com/Shopify/themekit/src/httpify.(*HTTPClient).Put(0xc0002b2800, 0xc0002cba00, 0x33, 0x14ee800, 0xc0000a8c30, 0xc0000a8c00, 0xd, 0x19fa1e0, 0x0)
        /Users/andyw8/src/github.com/Shopify/themekit/src/httpify/client.go:82 +0x7f
github.com/Shopify/themekit/src/shopify.Client.UpdateAsset(0xc000337960, 0xc, 0xc0002b0ce0, 0x20, 0x19dd860, 0xd, 0xd, 0x19fa1e0, 0x0, 0x0, ...)
        /Users/andyw8/src/github.com/Shopify/themekit/src/shopify/theme_client.go:293 +0x1fd
github.com/Shopify/themekit/cmd.perform(0xc000020b40, 0xc0000f0bd0, 0x26, 0x0, 0xc000215b20, 0x20)
        /Users/andyw8/src/github.com/Shopify/themekit/cmd/watch.go:123 +0xa44
github.com/Shopify/themekit/cmd.watch(0xc000020b40, 0xc00015c900, 0xc00015c960, 0x167bf00, 0x19fa450, 0x0, 0x0)
        /Users/andyw8/src/github.com/Shopify/themekit/cmd/watch.go:86 +0x6d7
github.com/Shopify/themekit/cmd.glob..func12.1(0xc000020b40, 0x0, 0x0)
        /Users/andyw8/src/github.com/Shopify/themekit/cmd/watch.go:58 +0x302
github.com/Shopify/themekit/src/cmdutil.forEachClient.func1(0x8, 0x159d220)
        /Users/andyw8/src/github.com/Shopify/themekit/src/cmdutil/util.go:288 +0x2e
golang.org/x/sync/errgroup.(*Group).Go.func1(0xc00001e6f0, 0xc000508d40)
        /Users/andyw8/go/pkg/mod/golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e/errgroup/errgroup.go:57 +0x57
created by golang.org/x/sync/errgroup.(*Group).Go
        /Users/andyw8/go/pkg/mod/golang.org/x/sync@v0.0.0-20190911185100-cd5d95a43a6e/errgroup/errgroup.go:54 +0x66