~sircmpwn/meta.sr.ht#188: 
[meta.sr.ht] GraphQL query error: runtime error: invalid memory address or nil pointer dereference

Error occured processing GraphQL request:

runtime error: invalid memory address or nil pointer dereference

When running the following query on behalf of (redacted):

        mutation UpdateProfile($input: UserInput!) {
            updateUser(input: $input) { id, email }
        }


With these variables:

{"input":{"bio":null,"location":"(redacted)","url":"(redacted)"}}

The following stack trace was produced:

goroutine 13424 [running]:
git.sr.ht/~sircmpwn/core-go/server.EmailRecover(0x56025f6243b8, 0xc00111f530, 0x56025f504da0, 0x56025fbc81e0, 0xc000255ec0, 0x56025e753254)
        /home/build/go/pkg/mod/git.sr.ht/~sircmpwn/core-go@v0.0.0-20220203103213-b2c8e81ee698/server/email.go:48 +0x278
github.com/99designs/gqlgen/graphql.(*OperationContext).Recover(0xc0005ee800, 0x56025f6243b8, 0xc00111f530, 0x56025f504da0, 0x56025fbc81e0, 0xc00033d388, 0x0)
        /home/build/go/pkg/mod/github.com/99designs/gqlgen@v0.14.0/graphql/context_operation.go:110 +0x58
git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api.(*executionContext)._Mutation_updateUser.func1(0xc0010dcec0, 0xc0010dcef0, 0xc00033e988)
        /home/build/sr.ht-apkbuilds/sr.ht/meta.sr.ht/src/meta.sr.ht-0.57.5/api/graph/api/generated.go:3191 +0x7e
panic(0x56025f504da0, 0x56025fbc81e0)
        /usr/lib/go/src/runtime/panic.go:965 +0x1b9
git.sr.ht/~sircmpwn/core-go/database.WithTx.func1(0xc0007d5b00)
        /home/build/go/pkg/mod/git.sr.ht/~sircmpwn/core-go@v0.0.0-20220203103213-b2c8e81ee698/database/middleware.go:59 +0x7f
panic(0x56025f504da0, 0x56025fbc81e0)
        /usr/lib/go/src/runtime/panic.go:965 +0x1b9
github.com/ProtonMail/go-crypto/openpgp.shouldPreferIdentity(0xc0003410e0, 0xc000341130, 0xc00033d701)
        /home/build/go/pkg/mod/github.com/!proton!mail/go-crypto@v0.0.0-20211112122917-428f8eabeeb3/openpgp/keys.go:102 +0x53
github.com/ProtonMail/go-crypto/openpgp.(*Entity).PrimaryIdentity(0xc000341040, 0xc07b1e0d792e1928)
        /home/build/go/pkg/mod/github.com/!proton!mail/go-crypto@v0.0.0-20211112122917-428f8eabeeb3/openpgp/keys.go:82 +0x9f
github.com/ProtonMail/go-crypto/openpgp.encrypt(0x7fd1da4179a8, 0xc000341220, 0x7fd1da4179a8, 0xc000341220, 0xc00033e000, 0x1, 0x1, 0xc0003409b0, 0x0, 0xc00033da01, ...)
        /home/build/go/pkg/mod/github.com/!proton!mail/go-crypto@v0.0.0-20211112122917-428f8eabeeb3/openpgp/write.go:373 +0x5e5
github.com/ProtonMail/go-crypto/openpgp.EncryptText(...)
        /home/build/go/pkg/mod/github.com/!proton!mail/go-crypto@v0.0.0-20211112122917-428f8eabeeb3/openpgp/write.go:190
github.com/emersion/go-pgpmail.Encrypt(0x56025f613928, 0xc0008cd5c0, 0xc00085e240, 0x7, 0x8, 0xc0008cc300, 0xc00033e000, 0x1, 0x1, 0xc0003409b0, ...)
        /home/build/go/pkg/mod/github.com/emersion/go-pgpmail@v0.2.0/writer.go:73 +0x6d6
git.sr.ht/~sircmpwn/core-go/email.EnqueueStd(0x56025f6243b8, 0xc00111f530, 0xc00085e240, 0x6, 0x8, 0xc0008cc300, 0x56025f614fe8, 0xc0010b9f00, 0xc000853690, 0x0, ...)
        /home/build/go/pkg/mod/git.sr.ht/~sircmpwn/core-go@v0.0.0-20220203103213-b2c8e81ee698/email/worker.go:149 +0xaee
git.sr.ht/~sircmpwn/meta.sr.ht/api/graph.sendEmailUpdateConfirmation(0x56025f6243b8, 0xc00111f530, 0xc0005e9ef0, 0xc000853690, 0xc0010506a8, 0x11, 0xc00003d050, 0x18)
        /home/build/sr.ht-apkbuilds/sr.ht/meta.sr.ht/src/meta.sr.ht-0.57.5/api/graph/resolver.go:275 +0xa91
git.sr.ht/~sircmpwn/meta.sr.ht/api/graph.(*mutationResolver).UpdateUser.func5(0xc0007d5b00, 0x0, 0x0)
        /home/build/sr.ht-apkbuilds/sr.ht/meta.sr.ht/src/meta.sr.ht-0.57.5/api/graph/schema.resolvers.go:163 +0x7c7
git.sr.ht/~sircmpwn/core-go/database.WithTx(0x56025f6243b8, 0xc00111f530, 0x0, 0xc00033e5e8, 0x0, 0x0)                                                                                                    
        /home/build/go/pkg/mod/git.sr.ht/~sircmpwn/core-go@v0.0.0-20220203103213-b2c8e81ee698/database/middleware.go:62 +0x117                                                                            
git.sr.ht/~sircmpwn/meta.sr.ht/api/graph.(*mutationResolver).UpdateUser(0xc000010dc0, 0x56025f6243b8, 0xc00111f530, 0xc00111f2f0, 0xc0008f73a8, 0xc00111f530, 0x56025f49f180)                             
        /home/build/sr.ht-apkbuilds/sr.ht/meta.sr.ht/src/meta.sr.ht-0.57.5/api/graph/schema.resolvers.go:101 +0x325                                                                                       
git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api.(*executionContext)._Mutation_updateUser.func2.1(0x56025f6243b8, 0xc00111f530, 0xc0006e0840, 0x203000, 0x8, 0x56025f6026f8)                                  
        /home/build/sr.ht-apkbuilds/sr.ht/meta.sr.ht/src/meta.sr.ht-0.57.5/api/graph/api/generated.go:3214 +0xf4                                                                                          
git.sr.ht/~sircmpwn/core-go/server.Access(0x56025f6243b8, 0xc00111f530, 0x0, 0x0, 0xc00084aec0, 0x56025ef85698, 0x7, 0x56025ef810fc, 0x2, 0x0, ...)                                                       
        /home/build/go/pkg/mod/git.sr.ht/~sircmpwn/core-go@v0.0.0-20220203103213-b2c8e81ee698/server/directives.go:55 +0x88                                                                               
main.main.func1(0x56025f6243b8, 0xc00111f530, 0x0, 0x0, 0xc00084aec0, 0x56025ef85698, 0x7, 0x56025ef810fc, 0x2, 0xc000055400, ...)                                                                        
        /home/build/sr.ht-apkbuilds/sr.ht/meta.sr.ht/src/meta.sr.ht-0.57.5/api/server.go:27 +0x99                                                                                                         
git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api.(*executionContext)._Mutation_updateUser.func2.2(0x56025f6243b8, 0xc00111f530, 0xc00084aea0, 0x20, 0x20, 0x56025f571f60)                                     
        /home/build/sr.ht-apkbuilds/sr.ht/meta.sr.ht/src/meta.sr.ht-0.57.5/api/graph/api/generated.go:3228 +0x17d                                                                                         
git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api.(*executionContext)._Mutation_updateUser.func2(0x56025f6243b8, 0xc00111f530, 0x20, 0x56025f571f60, 0xc00111f201, 0xc00084aea0)                               
        /home/build/sr.ht-apkbuilds/sr.ht/meta.sr.ht/src/meta.sr.ht-0.57.5/api/graph/api/generated.go:3231 +0xd1                                                                                          
github.com/99designs/gqlgen/graphql/executor.processExtensions.func3(0x56025f6243b8, 0xc00111f530, 0xc00084aea0, 0xc00111f560, 0xc00111f590, 0x0, 0x0)                                                    
        /home/build/go/pkg/mod/github.com/99designs/gqlgen@v0.14.0/graphql/executor/extensions.go:62 +0x3c                                                                                                
git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api.(*executionContext)._Mutation_updateUser(0xc0010dcec0, 0x56025f6243b8, 0xc00111f500, 0xc0007d5280, 0xc00084ae60, 0x2, 0x2, 0x0, 0x0)                         
        /home/build/sr.ht-apkbuilds/sr.ht/meta.sr.ht/src/meta.sr.ht-0.57.5/api/graph/api/generated.go:3211 +0x2cc                                                                                         
git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api.(*executionContext)._Mutation(0xc0010dcec0, 0x56025f6243b8, 0xc00111f500, 0xc0008a5fe0, 0x1, 0x1, 0x203000, 0xc00033ec00)                                    
        /home/build/sr.ht-apkbuilds/sr.ht/meta.sr.ht/src/meta.sr.ht-0.57.5/api/graph/api/generated.go:9901 +0x39d                                                                                         
git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api.(*executableSchema).Exec.func2(0x56025f6243b8, 0xc00111f4d0, 0x30)                                                                                           
        /home/build/sr.ht-apkbuilds/sr.ht/meta.sr.ht/src/meta.sr.ht-0.57.5/api/graph/api/generated.go:1485 +0x7d                                                                                          
github.com/99designs/gqlgen/graphql/executor.(*Executor).DispatchOperation.func1.1.1(0x56025f6243b8, 0xc00111f4d0, 0xc0010dced0)                                                                          
        /home/build/go/pkg/mod/github.com/99designs/gqlgen@v0.14.0/graphql/executor/executor.go:105 +0x45                                                                                                 
github.com/99designs/gqlgen/graphql/executor.processExtensions.func2(0x56025f6243b8, 0xc00111f4d0, 0xc0010dced0, 0x56025f602708)                                                                          
        /home/build/go/pkg/mod/github.com/99designs/gqlgen@v0.14.0/graphql/executor/extensions.go:59 +0x3c                                                                                                
github.com/99designs/gqlgen/graphql/executor.(*Executor).DispatchOperation.func1.1(0x56025f6243b8, 0xc00111f470, 0xc00111f440)                                                                            
        /home/build/go/pkg/mod/github.com/99designs/gqlgen@v0.14.0/graphql/executor/executor.go:104 +0x131                                                                                                
github.com/99designs/gqlgen/graphql/handler/transport.POST.Do(0x7fd1da580c08, 0xc0008f2c40, 0xc0005ee700, 0x56025f621870, 0xc00022f320)                                                                   
        /home/build/go/pkg/mod/github.com/99designs/gqlgen@v0.14.0/graphql/handler/transport/http_post.go:53 +0x3a5                                                                                       
github.com/99designs/gqlgen/graphql/handler.(*Server).ServeHTTP(0xc00023aea0, 0x7fd1da580c08, 0xc0008f2c40, 0xc0005ee700)                                                                                 
        /home/build/go/pkg/mod/github.com/99designs/gqlgen@v0.14.0/graphql/handler/server.go:115 +0x21b                                                                                                   
net/http.HandlerFunc.ServeHTTP(0xc000216370, 0x7fd1da580c08, 0xc0008f2c40, 0xc0005ee600)                                                                                                                  
        /usr/lib/go/src/net/http/server.go:2049 +0x46                                                                                                                                                     
github.com/go-chi/chi.(*Mux).routeHTTP(0xc0002b8f60, 0x7fd1da580c08, 0xc0008f2c40, 0xc0005ee600)                                                                                                          
        /home/build/go/pkg/mod/github.com/go-chi/chi@v4.1.2+incompatible/mux.go:431 +0x28b                                                                                                                
net/http.HandlerFunc.ServeHTTP(0xc000216390, 0x7fd1da580c08, 0xc0008f2c40, 0xc0005ee600)                                                                                                                  
        /usr/lib/go/src/net/http/server.go:2049 +0x46                                                                                                                                                     
git.sr.ht/~sircmpwn/meta.sr.ht/api/webhooks.LegacyMiddleware.func1.1(0x7fd1da580c08, 0xc0008f2c40, 0xc0005ee500)                                                                                          
        /home/build/sr.ht-apkbuilds/sr.ht/meta.sr.ht/src/meta.sr.ht-0.57.5/api/webhooks/legacy.go:38 +0x187                                                                                               
net/http.HandlerFunc.ServeHTTP(0xc00023af40, 0x7fd1da580c08, 0xc0008f2c40, 0xc0005ee500)                                                                                                                  
        /usr/lib/go/src/net/http/server.go:2049 +0x46                                                                                                                                                     
git.sr.ht/~sircmpwn/meta.sr.ht/api/webhooks.Middleware.func1.1(0x7fd1da580c08, 0xc0008f2c40, 0xc0005ee400)                                                                                                
        /home/build/sr.ht-apkbuilds/sr.ht/meta.sr.ht/src/meta.sr.ht-0.57.5/api/webhooks/middleware.go:22 +0x187                                                                                           
net/http.HandlerFunc.ServeHTTP(0xc00023af60, 0x7fd1da580c08, 0xc0008f2c40, 0xc0005ee400)                                                                                                                  
        /usr/lib/go/src/net/http/server.go:2049 +0x46                                                                                                                                                     
git.sr.ht/~sircmpwn/meta.sr.ht/api/loaders.Middleware.func1(0x7fd1da580c08, 0xc0008f2c40, 0xc0005ee300)                                                                                                   
[...]
Status
RESOLVED FIXED
Submitter
~sircmpwn
Assigned to
Submitted
9 months ago
Updated
8 months ago
Labels
No labels applied.

~bitfehler 8 months ago

I can't quite make sense of this. Here is what I have found so far.

  • The panic was triggered when encrypting a confirmation email to the user
  • In ProtonMail/go-crypto in this line

I cannot reproduce this with the query posted above. A confirmation email is only sent if someone changes their email address, which is seemingly not the case above. After staring at this for extended periods of time here is my best guess:

  1. The query above originally had the email parameter set
  2. It does not show up in the error message because it gets removed during validation
  3. Something went wrong during encryption of the message

I tried to reproduce, but successfully received an encrypted confirmation message when changing my email address.

Can you confirm that 1. and 2. make sense there?

Given the exact location where the panic was triggered, one option is that there is something funky with the user's PGP key. Would you be able to share it (in private)?

~sircmpwn REPORTED FIXED 8 months ago

~sircmpwn referenced this from #190 8 months ago

~bitfehler referenced this from #190 8 months ago

Register here or Log in to comment, or comment via email.