BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
14.68k stars 1.85k forks source link

[Bug Report]: Failed webhooks (Due to timeout or other) leads to "An Error Occured" #3122

Closed rusty1281 closed 2 years ago

rusty1281 commented 2 years ago

Describe the Bug

Looks like I have an issue with this on one of my docker instances (both using the same docker image).

One instance works just fine, and the other that is running via a reverse proxy does not. The RP instance runs great until I set up webhook. So it all works, creating, deleting, commenting, the works. But as soon as I activate a webook (regardless of what events), all other operations are complete but with an error.

So for example, create a new page, hit save and I get an internal error. The upside is that the new page does get created, same as any other operation (delete, move, comment) but all happen after the internal error.

As soon as I delete or disable the webhook, without even restarting the container, it all starts to work normally.

On my other, internal (non-RP) instance, it all works fine regardless of how many events or webooks I have active.

Has anyone had a chance to get the same or similar experience?

UPDATE: I have also tested this in a completely new docker instance with a fresh, empty DB, the same problem happens.

Steps to Reproduce

Activating a webhook will result in an "An error has occurred" message for any common tasks like create, update, delete or comment, etc.

Expected Behaviour

Common operations to complete without any error and webhook payload to be passed to the destination platform

Screenshots or Additional Context

Exact BookStack Version

v21.12

PHP Version

No response

Hosting Environment

Running in Docker using the current linuxserver image

geoffreyjt commented 2 years ago

Hello, I have the same issues, did you find something about fix ? Thanks in advance

rusty1281 commented 2 years ago

Hello, I have the same issues, did you find something about fix ? Thanks in advance

Nothing yet. Waiting for the response from DEV side on the matter.

ssddanbrown commented 2 years ago

Hi @rusty1281 @geoffreyjt , I've just updated and tested in one of my own linuxserver.io instances. All seems to work fine there so don't think it's down to the container image itself or usage within a container.

When you get that kind of error view, the error should be logged to the application log. This should be at www/laravel.log within the folder where you have mounted the /config volume to. Can you check in there, find the error logged when the above appears, then report back?

rusty1281 commented 2 years ago

Hello @ssddanbrown!

this is the log entry that I get after I configure and save the webhook

[2021-12-27 15:35:39] production.ERROR:  {"exception":"[object] (BookStack\\Exceptions\\StoppedAuthenticationException(code: 0):  at /var/www/html/app/Auth/Access/LoginService.php:40)          
[stacktrace]                                                                                                                                                                                     
#0 /var/www/html/app/Auth/Access/LoginService.php(159): BookStack\\Auth\\Access\\LoginService->login()                                                                                           
#1 /var/www/html/app/Http/Controllers/Auth/LoginController.php(151): BookStack\\Auth\\Access\\LoginService->attempt()                                                                            
#2 /var/www/html/app/Http/Controllers/Auth/LoginController.php(120): BookStack\\Http\\Controllers\\Auth\\LoginController->attemptLogin()                                                         
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): BookStack\\Http\\Controllers\\Auth\\LoginController->login()                                                
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction()                                                     
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(262): Illuminate\\Routing\\ControllerDispatcher->dispatch()                                                           
#6 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\\Routing\\Route->runController()                                                                     
#7 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(695): Illuminate\\Routing\\Route->run()                                                                              
#8 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()                                               
#9 /var/www/html/app/Http/Middleware/CheckGuard.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                                                       
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\CheckGuard->handle()                                                          
#11 /var/www/html/app/Http/Middleware/RedirectIfAuthenticated.php(31): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                                         
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\RedirectIfAuthenticated->handle()                                             
#13 /var/www/html/app/Http/Middleware/Localization.php(82): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                                                    
#14 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\Localization->handle()                                                        
#15 /var/www/html/app/Http/Middleware/RunThemeActions.php(26): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                                                 
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\RunThemeActions->handle()                                                     
#17 /var/www/html/app/Http/Middleware/CheckEmailConfirmed.php(47): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                                             
#18 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\CheckEmailConfirmed->handle()                                                 
#19 /var/www/html/app/Http/Middleware/PreventAuthenticatedResponseCaching.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                             
#20 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\PreventAuthenticatedResponseCaching->handle()                                 
#21 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                  
#22 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()                                        
#23 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                      
#24 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()                                             
#25 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                            
#26 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()                        
#27 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Session\\Middleware\\StartSession->handle()                                                    
#28 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                
#29 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()                                       
#30 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                            
#31 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()                                                   
#32 /var/www/html/app/Http/Middleware/ApplyCspRules.php(36): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                                                   
#33 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\ApplyCspRules->handle()                                                       
#34 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                          
#35 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(697): Illuminate\\Pipeline\\Pipeline->then()                                                                        
#36 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(672): Illuminate\\Routing\\Router->runRouteWithinStack()                                                            
#37 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(636): Illuminate\\Routing\\Router->runRoute()                                                                       
#38 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\\Routing\\Router->dispatchToRoute()                                                                
#39 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\\Routing\\Router->dispatch()                                                               
#40 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()                            
#41 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                
#42 /var/www/html/app/Http/Middleware/TrustProxies.php(41): Illuminate\\Http\\Middleware\\TrustProxies->handle()                                                                                 
#43 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\TrustProxies->handle()                                                        
#44 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                
#45 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()                  
#46 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()                                            
#47 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                 
#48 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()                                       
#49 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() 
#50 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()                       
#51 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                          
#52 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\\Pipeline\\Pipeline->then()                                                                
#53 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()                                      
#54 /var/www/html/public/index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle()                                                                                                           
#55 {main}                                                                     

This is what happens after webhooks should be initiated but it fails:

[previous exception] [object] (GuzzleHttp\\Exception\\ConnectException(code: 0): cURL error 28: Resolving timed out after 3000 milliseconds (see https://curl.haxx.se/libcurl/c/libcurl-errors.ht
ml) for https://MYFQDN/hooks/61c82f6bcbe4b4a97d82b507/kquNEmWnuPdYSZyRzgDnoLij64AXtsjSSGAkiZTr3njCz7Ge at /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:210)   
[stacktrace]                                                                                                                                                                                     
#0 /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(158): GuzzleHttp\\Handler\\CurlFactory::createRejection()                                                                  
#1 /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(110): GuzzleHttp\\Handler\\CurlFactory::finishError()                                                                      
#2 /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php(47): GuzzleHttp\\Handler\\CurlFactory::finish()                                                                            
#3 /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(28): GuzzleHttp\\Handler\\CurlHandler->__invoke()                                                                                
#4 /var/www/html/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(48): GuzzleHttp\\Handler\\Proxy::GuzzleHttp\\Handler\\{closure}()                                                                
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(925): GuzzleHttp\\Handler\\Proxy::GuzzleHttp\\Handler\\{closure}()                                       
#6 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(895): Illuminate\\Http\\Client\\PendingRequest->Illuminate\\Http\\Client\\{closure}()                    
#7 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(881): Illuminate\\Http\\Client\\PendingRequest->Illuminate\\Http\\Client\\{closure}()                    
#8 /var/www/html/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php(64): Illuminate\\Http\\Client\\PendingRequest->Illuminate\\Http\\Client\\{closure}()                                     
#9 /var/www/html/vendor/guzzlehttp/guzzle/src/Middleware.php(37): GuzzleHttp\\PrepareBodyMiddleware->__invoke()                                                                                  
#10 /var/www/html/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(71): GuzzleHttp\\Middleware::GuzzleHttp\\{closure}()                                                                       
#11 /var/www/html/vendor/guzzlehttp/guzzle/src/Middleware.php(61): GuzzleHttp\\RedirectMiddleware->__invoke()                                                                                    
#12 /var/www/html/vendor/guzzlehttp/guzzle/src/HandlerStack.php(75): GuzzleHttp\\Middleware::GuzzleHttp\\{closure}()                                                                             
#13 /var/www/html/vendor/guzzlehttp/guzzle/src/Client.php(331): GuzzleHttp\\HandlerStack->__invoke()                                                                                             
#14 /var/www/html/vendor/guzzlehttp/guzzle/src/Client.php(168): GuzzleHttp\\Client->transfer()                                                                                                   
#15 /var/www/html/vendor/guzzlehttp/guzzle/src/Client.php(187): GuzzleHttp\\Client->requestAsync()                                                                                               
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(748): GuzzleHttp\\Client->request()                                                                     
#17 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(679): Illuminate\\Http\\Client\\PendingRequest->sendRequest()                                           
#18 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/helpers.php(234): Illuminate\\Http\\Client\\PendingRequest->Illuminate\\Http\\Client\\{closure}()                              
#19 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(693): retry()                                                                                           
#20 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Client/PendingRequest.php(576): Illuminate\\Http\\Client\\PendingRequest->send()                                                  
#21 /var/www/html/app/Actions/DispatchWebhookJob.php(74): Illuminate\\Http\\Client\\PendingRequest->post()                                                                                       
#22 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): BookStack\\Actions\\DispatchWebhookJob->handle()                                                        
#23 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()                                         
#24 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure()                                                          
#25 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod()                                                   
#26 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\\Container\\BoundMethod::call()                                                               
#27 /var/www/html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(128): Illuminate\\Container\\Container->call()        
#28 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Bus\\Dispatcher->Illuminate\\Bus\\{closure}()                                                  
#29 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                          
#30 /var/www/html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(132): Illuminate\\Pipeline\\Pipeline->then()                                                                        
#31 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(120): Illuminate\\Bus\\Dispatcher->dispatchNow()                                                           
#32 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Queue\\CallQueuedHandler->Illuminate\\Queue\\{closure}()                                       
#33 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                          
#34 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(122): Illuminate\\Pipeline\\Pipeline->then()                                                               
#35 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php(70): Illuminate\\Queue\\CallQueuedHandler->dispatchThroughMiddleware()                                     
#36 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(98): Illuminate\\Queue\\CallQueuedHandler->call()                                                                   
#37 /var/www/html/vendor/laravel/framework/src/Illuminate/Queue/SyncQueue.php(43): Illuminate\\Queue\\Jobs\\Job->fire()                                                                          
#38 /var/www/html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(253): Illuminate\\Queue\\SyncQueue->push()                                                                          
#39 /var/www/html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(229): Illuminate\\Bus\\Dispatcher->pushCommandToQueue()                                                             
#40 /var/www/html/vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php(77): Illuminate\\Bus\\Dispatcher->dispatchToQueue()                                                                 
#41 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bus/PendingDispatch.php(193): Illuminate\\Bus\\Dispatcher->dispatch()                                                       
#42 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(389): Illuminate\\Foundation\\Bus\\PendingDispatch->__destruct()                                                
#43 /var/www/html/app/Actions/ActivityLogger.php(96): dispatch()                                                                                                                                 
#44 /var/www/html/app/Actions/ActivityLogger.php(39): BookStack\\Actions\\ActivityLogger->dispatchWebhooks()                                                                                     
#45 /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(261): BookStack\\Actions\\ActivityLogger->add()                                                             
#46 /var/www/html/app/Entities/Repos/PageRepo.php(174): Illuminate\\Support\\Facades\\Facade::__callStatic()                                                                                     
#47 /var/www/html/app/Http/Controllers/PageController.php(116): BookStack\\Entities\\Repos\\PageRepo->publishDraft()                                                                             
#48 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): BookStack\\Http\\Controllers\\PageController->store()                                                      
#49 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction()                                                    
#50 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(262): Illuminate\\Routing\\ControllerDispatcher->dispatch()                                                          
#51 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\\Routing\\Route->runController()                                                                    
#52 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(695): Illuminate\\Routing\\Route->run()                                                                             
#53 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()                                              
#54 /var/www/html/app/Http/Middleware/Authenticate.php(23): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                                                    
#55 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\Authenticate->handle()                                                        
#56 /var/www/html/app/Http/Middleware/Localization.php(82): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                                                    
#57 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\Localization->handle()                                                        
#58 /var/www/html/app/Http/Middleware/RunThemeActions.php(26): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                                                 
#59 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\RunThemeActions->handle()                                                     
#60 /var/www/html/app/Http/Middleware/CheckEmailConfirmed.php(47): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                                             
#61 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\CheckEmailConfirmed->handle()                                                 
#62 /var/www/html/app/Http/Middleware/PreventAuthenticatedResponseCaching.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                             
#63 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\PreventAuthenticatedResponseCaching->handle()                                 
#64 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                  
#65 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()                                        
#66 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                      
#67 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()                                             
#68 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                            
#69 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()                        
#70 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Session\\Middleware\\StartSession->handle()                                                    
#71 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                
#72 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()                                       
#73 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                            
#74 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()                                                   
#75 /var/www/html/app/Http/Middleware/ApplyCspRules.php(36): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                                                   
#76 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\ApplyCspRules->handle()                                                       
#77 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                          
#78 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(697): Illuminate\\Pipeline\\Pipeline->then()                                                                        
#79 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(672): Illuminate\\Routing\\Router->runRouteWithinStack()                                                            
#80 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(636): Illuminate\\Routing\\Router->runRoute()                                                                       
#81 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(625): Illuminate\\Routing\\Router->dispatchToRoute()                                                                
#82 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\\Routing\\Router->dispatch()                                                               
#83 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()                            
#84 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                
#85 /var/www/html/app/Http/Middleware/TrustProxies.php(41): Illuminate\\Http\\Middleware\\TrustProxies->handle()                                                                                 
#86 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): BookStack\\Http\\Middleware\\TrustProxies->handle()                                                        
#87 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                
#88 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()                  
#89 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()                                            
#90 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                 
#91 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()                                       
#92 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}() 
#93 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()                       
#94 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()                                          
#95 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\\Pipeline\\Pipeline->then()                                                                
#96 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()                                      
#97 /var/www/html/public/index.php(53): Illuminate\\Foundation\\Http\\Kernel->handle()                                                                                                           
#98 {main}  

The error does happen about 3 sec after the action is initiated. Visiting the site from the log, I get this.

Screenshot 2021-12-27 at 16 43 46

Regards!

ssddanbrown commented 2 years ago

@rusty1281 Thanks for providing.

Webhook request errors are supposed to be caught and reported to the log (In a simpler format at least) without causing error but looks like something is not handling errors as I originally expected. Will look to update that to prevent failures causing such error views.

In your case the request is hitting a timeout (It's hardcoded at 3s). Based on it saying "resolving timeout" I'm assuming this is a failure to resolve the webhook host/IP entirely. This could be down to networking at any point from PHP within the container making the curl request, up to the webhook host.

Can the URL be reached from within the container? Could test via:

# Find container id
docker ps

# Enter the bookstack container via bash
docker exec -it <container_id> /bin/bash

# Once inside, Curl to the webhook endpoint
curl <webhook_endpoint>
rusty1281 commented 2 years ago

Can the URL be reached from within the container?

Yes, it can, works fine.

root@8469d53ab6c0:/# curl https://MYFQND/hooks/61c82f6bcbe4b4a97d82b507/kquNEmWnuPdYSZyRzgDnoLij64AXtsjSSGAkiZTr3njCz7Ge
{"success":true}root@8469d53ab6c0:/# 
ssddanbrown commented 2 years ago

@rusty1281 Hmmm :thinking: Does the curl return instantly? Within 3 seconds or does it take a little while?

rusty1281 commented 2 years ago

@rusty1281 Hmmm 🤔 Does the curl return instantly? Within 3 seconds or does it take a little while?

about 4.5 seconds

update: on the instance that is not running behind a reverse proxy it is instant, but that instance is also not on the same docker host as the one that is behind reverse proxy

ssddanbrown commented 2 years ago

about 4.5 seconds

Okay, might be legitimately hitting our 3s timeout then, might need to make that configurable.

on the instance that is not running behind a reverse proxy it is instant, but that instance is also not on the same docker host as the one that is behind reverse proxy

To be honest, I'm not sure if the reverse proxy should affect things. These webhook requests would typically be direct to the network from the BookStack container, rather than via proxy. A different host/network/dns-resolution/outbound-proxy could affect things for sure.

rusty1281 commented 2 years ago

To be honest, I'm not sure if the reverse proxy should affect things. These webhook requests would typically be direct to the network from the BookStack container, rather than via proxy. A different host/network/dns-resolution/outbound-proxy could affect things for sure.

I have configured the reverse proxy instance to use the non-FQDN name for the webhook (considering that source and destination are both in the same network), and it works just fine now.

This is an acceptable solution for me, so we can consider this matter closed imho.

@ssddanbrown thank you for your time and effort on this matter as well as on the whole Bookstack platform.

Regards!

ssddanbrown commented 2 years ago

@rusty1281 Glad I could help you to a solution.

Instead of closing this I'll update the title to focus it on preventing an error in such similar webhook request failure scenarios, for easier debugging and non-interruption of normal use.

rusty1281 commented 2 years ago

Glad I could help you to a solution.

Thank you again. Send some $$ for your troubles.

southeasterntech commented 2 years ago

I believe I'm getting a similar error after upgrading to 21.12, with no webhooks enabled.

"So for example, create a new page, hit save and I get an internal error. The upside is that the new page does get created, same as any other operation (delete, move, comment) but all happen after the internal error."

This is what I'm getting on our own self-hosted server on our LAN running Ubuntu 20.04

image

ssddanbrown commented 2 years ago

@southeasterntech This sounds like a separate issue. I'd guess the database migrations were not ran or failed during the upgrade process. It would be best to open a new issue report with any detail from your BookStack log provided.

southeasterntech commented 2 years ago

OK! I'll make a new thread! thanks Dan

ssddanbrown commented 2 years ago

I've now made a series of updates to webhooks, with this issue thread in mind, which will be part of the next patch release (v21.12.1):

Since the above should greatly cover the troubles experienced here I'll close this off.

chrisbehectik commented 5 months ago

I think I have a similiar issue.

I'm trying to set-up a Discord webhook but any time an event is triggered I get "Response status from endpoint was 400"

I can curl in both db and app container giving me the following. image: lscr.io/linuxserver/bookstack

curl https://discord.com/api/webhooks/xxx
{"application_id":null,"avatar":null,"channel_id":"1217070086230380645","guild_id":"171354855716159498","id":"1217070393504829470","name":"Astro-tech_notes","type":1,"user":{"id":"166021676209799170","username":"christbehectik","avatar":"5432b2e5ec550ac703e12a3335bbf260","discriminator":"0","public_flags":128,"premium_type":0,"flags":128,"banner":null,"accent_color":40734,"global_name":"Hectik","avatar_decoration_data":null,"banner_color":"#009f1e"},"token":"TOKEN","url":"https://discord.com/api/webhooks/xxx"}

image: lscr.io/linuxserver/mariadb

curl https://discord.com/api/webhooks/xxx
{"application_id":null,"avatar":null,"channel_id":"1217070086230380645","guild_id":"171354855716159498","id":"1217070393504829470","name":"Astro-tech_notes","type":1,"user":{"id":"166021676209799170","username":"christbehectik","avatar":"5432b2e5ec550ac703e12a3335bbf260","discriminator":"0","public_flags":128,"premium_type":0,"flags":128,"banner":null,"accent_color":40734,"global_name":"Hectik","avatar_decoration_data":null,"banner_color":"#009f1e"},"token":"TOKEN","url":"https://discord.com/api/webhooks/xxx"}

Logs give me:

[2024-03-12 15:25:40] production.ERROR: Webhook call to endpoint https://discord.com/api/webhooks/xxx failed with status 400  
[2024-03-12 15:44:45] production.ERROR: Webhook call to endpoint https://discord.com/api/webhooks/xxx failed with status 400  
[2024-03-12 15:58:49] production.ERROR: Webhook call to endpoint https://discord.com/api/webhooks/xxx failed with status 400  
[2024-03-12 16:02:29] production.ERROR: Webhook call to endpoint https://discord.com/api/webhooks/xxx failed with status 400  
[2024-03-12 16:02:38] production.ERROR: Webhook call to endpoint https://discord.com/api/webhooks/xxx failed with status 400  

Not sure what the issue is exactly. Any help would be appreciated.

Note: Replaced end of endpoint URL for anonimity.

ssddanbrown commented 5 months ago

@chrisbehectik Try adding /slack to the end of the URL. I demo webhooks, including usage with discord, in my video here: https://www.youtube.com/watch?v=_zIp1ruGpoI

If you need further help, please open a new support thread.