Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Signup fails with #284

Closed
1 of 2 tasks
rickmak opened this issue Feb 9, 2017 · 2 comments
Closed
1 of 2 tasks

Signup fails with #284

rickmak opened this issue Feb 9, 2017 · 2 comments
Assignees

Comments

@rickmak
Copy link
Member

rickmak commented Feb 9, 2017

If the plugin have any user before_save hook in plugin. The skygear-server will fails user signup with error.

This is the example of plugin code that will trigger the bugs.

@skygear.before_save("user", async=False)
def handle_user_before_save(record, original_record, db):
    return
  • Skygear Server Date/Version: server 0.21.1, python 0.21.0
  • Application Platform: Python
  • Is this a regression?
  • Attached logs, screenshots

Expected Results

The user sign up successfully.

Actual Results

User will get follow error

{
    "error": {
        "code": 10000, 
        "message": "panic occurred while handling request: runtime error: invalid memory address or nil pointer dereference", 
        "name": "UnexpectedError"
    }
}

Stacktrace

ERRO[0009] goroutine 70 [running]:
runtime/debug.Stack(0x45724e0, 0x456bbc0, 0xc42000c0e0)
	/usr/local/Cellar/go/1.7.1/libexec/src/runtime/debug/stack.go:24 +0x79
github.com/skygeario/skygear-server/pkg/server/router.errorFromRecoveringPanic(0x456bbc0, 0xc42000c0e0, 0xc42000c0e0, 0x40148e6)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/router/errors.go:61 +0x1c5
github.com/skygeario/skygear-server/pkg/server/router.(*Router).ServeHTTP.func1(0xc4202c5730, 0x46606c1, 0x6, 0xc4202f3940)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/router/router.go:107 +0x310
panic(0x456bbc0, 0xc42000c0e0)
	/usr/local/Cellar/go/1.7.1/libexec/src/runtime/panic.go:458 +0x243
encoding/json.(*encodeState).marshal.func1(0xc4202f29a0)
	/usr/local/Cellar/go/1.7.1/libexec/src/encoding/json/encode.go:272 +0x1b9
panic(0x456bbc0, 0xc42000c0e0)
	/usr/local/Cellar/go/1.7.1/libexec/src/runtime/panic.go:458 +0x243
context.(*valueCtx).Value(0xc4202a5470, 0x453a5e0, 0xc4202f78e0, 0x453a5e0, 0xc4202f78e0)
	/usr/local/Cellar/go/1.7.1/libexec/src/context/context.go:472 +0x3f
github.com/skygeario/skygear-server/pkg/server/plugin.ContextMap(0x54847a8, 0xc4202a5470, 0xc4202f2800)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/plugin/transport.go:104 +0xd2
github.com/skygeario/skygear-server/pkg/server/plugin/request.(*Request).MarshalJSON(0xc4202dea00, 0x455d060, 0xc4202dea00, 0xc4202f28f0, 0xc4202dea00, 0x48af560)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/plugin/request/request.go:79 +0x4c
encoding/json.marshalerEncoder(0xc4201cdad0, 0x455d060, 0xc4202dea00, 0x16, 0xc4202d0100)
	/usr/local/Cellar/go/1.7.1/libexec/src/encoding/json/encode.go:431 +0xb1
encoding/json.(*encodeState).reflectValue(0xc4201cdad0, 0x455d060, 0xc4202dea00, 0x16, 0x100)
	/usr/local/Cellar/go/1.7.1/libexec/src/encoding/json/encode.go:307 +0x82
encoding/json.(*encodeState).marshal(0xc4201cdad0, 0x455d060, 0xc4202dea00, 0x100, 0x0, 0x0)
	/usr/local/Cellar/go/1.7.1/libexec/src/encoding/json/encode.go:280 +0xb8
encoding/json.Marshal(0x455d060, 0xc4202dea00, 0x465e8dc, 0xc41ffe7cf4, 0x0, 0x515b4b0, 0xc41ffe7cff)
	/usr/local/Cellar/go/1.7.1/libexec/src/encoding/json/encode.go:145 +0x8f
github.com/skygeario/skygear-server/pkg/server/plugin/http.(*httpTransport).ipc(0xc420244000, 0xc4202dea00, 0x0, 0x0, 0x0, 0x0, 0x0)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/plugin/http/http.go:87 +0x9e
github.com/skygeario/skygear-server/pkg/server/plugin/http.(*httpTransport).rpc(0xc420244000, 0xc4202dea00, 0xc4202f9240, 0x4591440, 0xc4202f9240, 0x4573260, 0xc420306000)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/plugin/http/http.go:49 +0x50
github.com/skygeario/skygear-server/pkg/server/plugin/http.(*httpTransport).RunHook(0xc420244000, 0x54847a8, 0xc4202a5470, 0xc4202a4000, 0x26, 0xc4201f6300, 0x0, 0x1, 0xc420154130, 0x1)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/plugin/http/http.go:134 +0x143
github.com/skygeario/skygear-server/pkg/server/plugin.CreateHookFunc.func1(0x54847a8, 0xc4202a5470, 0xc4201f6300, 0x0, 0x4, 0xc420154210)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/plugin/hook.go:28 +0x96
github.com/skygeario/skygear-server/pkg/server/plugin/hook.(*Registry).ExecuteHooks(0xc42015cb40, 0x54847a8, 0xc4202a5470, 0x460b331, 0xa, 0xc4201f6300, 0x0, 0x20, 0x18)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/plugin/hook/hook.go:96 +0xcf
github.com/skygeario/skygear-server/pkg/server/handler.recordSaveHandler.func2(0xc4201f6300, 0xc4202f9220, 0x0)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/handler/recordutil.go:223 +0xad
github.com/skygeario/skygear-server/pkg/server/handler.executeRecordFunc(0xc420154208, 0x1, 0x1, 0xc4202a5a40, 0xc4202f9220, 0xc420154208, 0x1, 0x1)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/handler/recordutil.go:297 +0x88
github.com/skygeario/skygear-server/pkg/server/handler.recordSaveHandler(0xc4201d07e0, 0xc4202f30a8, 0xc4202a5a40, 0x0)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/handler/recordutil.go:225 +0xa0c
github.com/skygeario/skygear-server/pkg/server/handler.(*createUserWithRecordContext).execute.func1(0xc4202b3380, 0x0)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/handler/auth.go:551 +0x426
github.com/skygeario/skygear-server/pkg/server/handler.withTransaction(0x54847e8, 0xc4202b3380, 0xc4202f3308, 0xc4201ef308, 0x1)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/handler/recordutil.go:69 +0x52
github.com/skygeario/skygear-server/pkg/server/handler.(*createUserWithRecordContext).execute(0xc4202f34f8, 0xc420175980, 0x48c6f00, 0x0)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/handler/auth.go:552 +0x127
github.com/skygeario/skygear-server/pkg/server/handler.(*SignupHandler).Handle(0xc4201d0090, 0xc4202e0000, 0xc4202c5730)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/handler/auth.go:169 +0x8de
github.com/skygeario/skygear-server/pkg/server/router.(*Router).ServeHTTP(0xc4201a8ee0, 0x48a8040, 0xc4201d05a0, 0xc420292870)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/router/router.go:150 +0x277
net/http.(*ServeMux).ServeHTTP(0xc42015b470, 0x48a8040, 0xc4201d05a0, 0xc420292870)
	/usr/local/Cellar/go/1.7.1/libexec/src/net/http/server.go:2022 +0x7f
github.com/skygeario/skygear-server/pkg/server/router.(*CORSMiddleware).ServeHTTP(0xc420240480, 0x48a8040, 0xc4201d05a0, 0xc420292870)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/router/cors.go:48 +0x1d9
github.com/skygeario/skygear-server/pkg/server/router.(*LoggingMiddleware).ServeHTTP(0xc4200e4c80, 0x48a9680, 0xc4201e96c0, 0xc420292870)
	/Users/rickmak/go/src/github.com/skygeario/skygear-server/pkg/server/router/logging.go:107 +0x76f
net/http.serverHandler.ServeHTTP(0xc420174c80, 0x48a9680, 0xc4201e96c0, 0xc420292870)
	/usr/local/Cellar/go/1.7.1/libexec/src/net/http/server.go:2202 +0x7d
net/http.(*conn).serve(0xc420175700, 0x48a9f00, 0xc4202b7d00)
	/usr/local/Cellar/go/1.7.1/libexec/src/net/http/server.go:1579 +0x4b7
created by net/http.(*Server).Serve
	/usr/local/Cellar/go/1.7.1/libexec/src/net/http/server.go:2293 +0x44d
  logger=router
@cheungpat
Copy link
Contributor

I see. This is because it is the router that is responsible for injecting the User ID to the context (through the auth preprocessor). In this case, the User ID does not exists because the user is being created.

@cheungpat
Copy link
Contributor

No. Interesting. I already have a test case for that.

cheungpat added a commit to cheungpat/skygear-server that referenced this issue Feb 9, 2017
@cheungpat cheungpat self-assigned this Feb 9, 2017
rickmak pushed a commit that referenced this issue Feb 9, 2017
cheungpat added a commit to cheungpat/skygear-server that referenced this issue Feb 9, 2017
This fix is backported to apply on v0.21 branch.

refs SkygearIO#284
rickmak pushed a commit that referenced this issue Feb 9, 2017
This fix is backported to apply on v0.21 branch.

refs #284
@royuen royuen changed the title Signup fails with Signup fails with Feb 14, 2017
@royuen royuen closed this as completed Feb 14, 2017
@royuen royuen removed the In Review label Feb 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants