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

hook runtime error: invalid memory address or nil pointer dereference #1885

Closed
NickUfer opened this issue Oct 25, 2021 · 0 comments · Fixed by #1890
Closed

hook runtime error: invalid memory address or nil pointer dereference #1885

NickUfer opened this issue Oct 25, 2021 · 0 comments · Fixed by #1890

Comments

@NickUfer
Copy link
Contributor

Describe the bug

I configured a webhook for after registration. Kratos serves a 503 response.

Reproducing the bug

Steps to reproduce the behavior:

Server logs

2021/10/25 22:39:41 http: panic serving 10.88.0.1:53506: runtime error: invalid memory address or nil pointer dereference
goroutine 115 [running]:
net/http.(*conn).serve.func1(0xc0000b0140)
	/usr/local/go/src/net/http/server.go:1824 +0x153
panic(0x1560460, 0x2317060)
	/usr/local/go/src/runtime/panic.go:971 +0x499
bytes.(*Reader).Len(...)
	/usr/local/go/src/bytes/reader.go:27
net/http.NewRequestWithContext(0x19eb4a8, 0xc000040060, 0xc000766508, 0x4, 0xc00143f120, 0x1b, 0x19c3b40, 0x0, 0x0, 0x19c4b40, ...)
	/usr/local/go/src/net/http/request.go:897 +0x435
net/http.NewRequest(...)
	/usr/local/go/src/net/http/request.go:828
github.com/ory/kratos/selfservice/hook.doHttpCall(0xc000766508, 0x4, 0xc00143f120, 0x1b, 0x19c4b40, 0x2512c88, 0x19c3b40, 0x0, 0x40e398, 0x40)
	/home/ory/selfservice/hook/web_hook.go:311 +0x99
github.com/ory/kratos/selfservice/hook.(*WebHook).execute(0xc0009a6ae0, 0xc000188180, 0x0, 0x0)
	/home/ory/selfservice/hook/web_hook.go:266 +0x208
github.com/ory/kratos/selfservice/hook.(*WebHook).ExecutePostRegistrationPostPersistHook(0xc0009a6ae0, 0x7f820f33ef08, 0xc00000e278, 0xc001124b00, 0xc000900680, 0xc001528460, 0x3, 0x4)
	/home/ory/selfservice/hook/web_hook.go:229 +0xd4
github.com/ory/kratos/selfservice/flow/registration.(*HookExecutor).PostRegistrationHook(0xc00117aa10, 0x7f820f33ef08, 0xc00000e278, 0xc001124b00, 0x176085e, 0x8, 0xc000900680, 0xc000a5c000, 0x1627da0, 0xc000d00000)
	/home/ory/selfservice/flow/registration/hook.go:143 +0xc79
github.com/ory/kratos/selfservice/flow/registration.(*Handler).submitFlow(0xc000ada6b0, 0x7f820f33ef08, 0xc00000e278, 0xc001124b00, 0x0, 0x0, 0x0)
	/home/ory/selfservice/flow/registration/handler.go:407 +0x5e8
github.com/ory/kratos/session.(*Handler).IsNotAuthenticated.func1(0x7f820f33ef08, 0xc00000e278, 0xc001124b00, 0x0, 0x0, 0x0)
	/home/ory/session/handler.go:176 +0x48c
github.com/ory/kratos/x.NoCacheHandler.func1(0x7f820f33ef08, 0xc00000e278, 0xc001124b00, 0x0, 0x0, 0x0)
	/home/ory/x/nocache.go:18 +0x83
github.com/julienschmidt/httprouter.(*Router).ServeHTTP(0xc000aac5a0, 0x7f820f33ef08, 0xc00000e278, 0xc001124b00)
	/go/pkg/mod/github.com/julienschmidt/[email protected]/router.go:387 +0xc7e
github.com/ory/nosurf.(*CSRFHandler).handleSuccess(...)
	/go/pkg/mod/github.com/ory/[email protected]/handler.go:201
github.com/ory/nosurf.(*CSRFHandler).ServeHTTP(0xc0001b4e70, 0x7f820f33ef08, 0xc00000e278, 0xc001124a00)
	/go/pkg/mod/github.com/ory/[email protected]/handler.go:152 +0x7b0
github.com/urfave/negroni.Wrap.func1(0x7f820f33ef08, 0xc00000e278, 0xc001124a00, 0xc000128100)
	/go/pkg/mod/github.com/urfave/[email protected]/negroni.go:46 +0x4d
github.com/urfave/negroni.HandlerFunc.ServeHTTP(0xc000a90d20, 0x7f820f33ef08, 0xc00000e278, 0xc001124a00, 0xc000128100)
	/go/pkg/mod/github.com/urfave/[email protected]/negroni.go:29 +0x4e
github.com/urfave/negroni.middleware.ServeHTTP(0x19c80a0, 0xc000a90d20, 0xc000a911d0, 0x7f820f33ef08, 0xc00000e278, 0xc001124a00)
	/go/pkg/mod/github.com/urfave/[email protected]/negroni.go:38 +0x9c
github.com/ory/kratos/x.glob..func1(0x7f820f33ef08, 0xc00000e278, 0xc001124a00, 0xc0001280e0)
	/home/ory/x/clean_url.go:12 +0x8b
github.com/urfave/negroni.HandlerFunc.ServeHTTP(0x1843e60, 0x7f820f33ef08, 0xc00000e278, 0xc001124a00, 0xc0001280e0)
	/go/pkg/mod/github.com/urfave/[email protected]/negroni.go:29 +0x4e
github.com/urfave/negroni.middleware.ServeHTTP(0x19c80a0, 0x1843e60, 0xc000a911b8, 0x7f820f33ef08, 0xc00000e278, 0xc001124a00)
	/go/pkg/mod/github.com/urfave/[email protected]/negroni.go:38 +0x9c
github.com/urfave/negroni.(*Negroni).ServeHTTP(0xc000691aa0, 0x19e4fd8, 0xc000d9c7e0, 0xc001124a00)
	/go/pkg/mod/github.com/urfave/[email protected]/negroni.go:96 +0xf1
github.com/rs/cors.(*Cors).Handler.func1(0x19e4fd8, 0xc000d9c7e0, 0xc001124a00)
	/go/pkg/mod/github.com/rs/[email protected]/cors.go:207 +0x1b1
net/http.HandlerFunc.ServeHTTP(0xc000a6c100, 0x19e4fd8, 0xc000d9c7e0, 0xc001124a00)
	/usr/local/go/src/net/http/server.go:2069 +0x44
net/http.serverHandler.ServeHTTP(0xc000ae00e0, 0x19e4fd8, 0xc000d9c7e0, 0xc001124a00)
	/usr/local/go/src/net/http/server.go:2887 +0xa3
net/http.(*conn).serve(0xc0000b0140, 0x19eb518, 0xc000188400)
	/usr/local/go/src/net/http/server.go:1952 +0x8cd
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:3013 +0x39b

Server configuration

version: v0.7.6-alpha.1

dsn: postgres://user:[email protected]:5432/kratos?sslmode=disable

serve:
  public:
    base_url: https://example.com/
    cors:
      enabled: true
  admin:
    base_url: http://kratos:4434/

selfservice:
  default_browser_return_url: https://example.com/
  whitelisted_return_urls:
    - https://example.com

  methods:
    password:
      enabled: true

  flows:
    error:
      ui_url: https://example.com/error

    settings:
      ui_url: https://example.com/settings
      privileged_session_max_age: 15m

    recovery:
      enabled: true
      ui_url: https://example.com/recovery

    verification:
      enabled: true
      ui_url: https://example.com/verify
      after:
        default_browser_return_url: https://example.com/

    logout:
      after:
        default_browser_return_url: https://example.com/auth/login

    login:
      ui_url: https://example.com/auth/login
      lifespan: 10m

    registration:
      lifespan: 10m
      ui_url: https://example.com/auth/register
      after:
        password:
          hooks:
            - hook: web_hook
              config:
                url: 'https://example.com/somewebhook'
                method: 'GET'
            - hook: session

log:
  level: info
  format: text
  leak_sensitive_values: true

secrets:
  cookie:
    - omitted

hashers:
  argon2:
    parallelism: 1
    memory: 128MB
    iterations: 2
    salt_length: 16
    key_length: 16

identity:
  default_schema_url: file:///etc/kratos/schemas/v1/person.schema.json

courier:
  smtp:
    connection_uri: smtps://test:test@mailslurper:1025/?skip_ssl_verify=true&legacy_ssl=true

Expected behavior

The webhook is called.

Environment

  • Version: v0.7.6
  • Environment: Docker
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 a pull request may close this issue.

1 participant