supertokens / docs

SuperTokens documentation
39 stars 66 forks source link

fix: Resolve the potential panic error in the Go version example in implementing-deduplication.mdx. #810

Closed dkkb closed 2 weeks ago

dkkb commented 3 weeks ago

Summary of change

If we don't check the error is nil, the code will panic if there's no error in it.

2024/07/06 21:10:34 [Recovery] 2024/07/06 - 21:10:34 panic recovered:
runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:261 (0x100495407)
    panicmem: panic(memoryError)
/usr/local/go/src/runtime/signal_unix.go:881 (0x1004953d4)
    sigpanic: panicmem()
/Users/da/github/xxx/server/supertokens.go:161 (0x100d09604)
    InitSuperToken.thirdPartyAPIOverride.func3.1: if err.Error() == "Cannot sign up as email already exists" {
/Users/da/go/pkg/mod/github.com/supertokens/supertokens-golang@v0.22.0/recipe/thirdparty/api/signinup.go:82 (0x100bc09bb)
    SignInUpAPI: result, err := (*apiImplementation.SignInUpPOST)(provider, input, tenantId, options, userContext)
/Users/da/go/pkg/mod/github.com/supertokens/supertokens-golang@v0.22.0/recipe/thirdparty/recipe.go:147 (0x100bc2357)
    (*Recipe).handleAPIRequest: return api.SignInUpAPI(r.APIImpl, tenantId, options, userContext)
/Users/da/go/pkg/mod/github.com/supertokens/supertokens-golang@v0.22.0/supertokens/supertokens.go:261 (0x100a4241f)
    (*superTokens).middleware.func2: apiErr := finalMatchedRecipe.HandleAPIRequest(*id, tenantId, r, dw, theirHandler.ServeHTTP, path, method, userContext)
/usr/local/go/src/net/http/server.go:2166 (0x10073db07)
    HandlerFunc.ServeHTTP: f(w, r)

Related issues

N/A

Checklist

Remaining TODOs for this PR

N/A

netlify[bot] commented 3 weeks ago

Deploy Preview for admiring-bhabha-7b1be9 ready!

Name Link
Latest commit a15ba588a81e3abc5179dc07364c174f4a9986cf
Latest deploy log https://app.netlify.com/sites/admiring-bhabha-7b1be9/deploys/6689471ff278150008040dee
Deploy Preview https://deploy-preview-810--admiring-bhabha-7b1be9.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

rishabhpoddar commented 2 weeks ago

Thanks @dkkb