KelkooGroup / theGardener

theGardener will help you to include the documentation in your development loop so that you will trust again the documentation you provide.
https://thegardener.kelkoogroup.com
Apache License 2.0
20 stars 4 forks source link

[OpenAPI] Fail loading page if included OpenAPI is not available #575

Closed loriepisicchio closed 3 years ago

loriepisicchio commented 4 years ago

Acutal behavior When including a piece of OpenAPI in a page, when the OpenAPI URL is not responding, then the page doesn't load and we get the following issue on the server

2020-02-28 13:20:55,167 - [ERROR] - from application in application-akka.actor.default-dispatcher-779 ?.?:? 

! @7f20pb1kb - Internal server error, for (GET) [/api/pages?path=shoppingFeedsService%3Efeature/PUB-3506-write-doc%3E/Features/GetOfferFeed] ->

play.api.UnexpectedException: Unexpected exception[TimeoutException: Request timeout to dc1-papi-dev-feedsws-01.dev.dc1.kelkoo.net:9000 after 120000 ms]
    at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:340)
    at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:263)
    at play.core.server.AkkaHttpServer$$anonfun$1.applyOrElse(AkkaHttpServer.scala:443)
    at play.core.server.AkkaHttpServer$$anonfun$1.applyOrElse(AkkaHttpServer.scala:441)
    at scala.concurrent.Future.$anonfun$recoverWith$1(Future.scala:417)
    at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41)
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64)
    at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)
    at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:92)
    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
    at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85)
    at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:92)
    at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:41)
    at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:49)
    at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: java.util.concurrent.TimeoutException: Request timeout to dc1-papi-dev-feedsws-01.dev.dc1.kelkoo.net:9000 after 120000 ms
    at play.shaded.ahc.org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43)
    at play.shaded.ahc.org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:50)
    at play.shaded.ahc.io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:670)
    at play.shaded.ahc.io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:745)
    at play.shaded.ahc.io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:473)
    at play.shaded.ahc.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:748)

Expected behavior Page should load and an error should be displayed instead of the OpenAPI information

GeReinhart commented 4 years ago

I think the main issue is that the page is not loading properly. The application shouldn't break

I'm not convinced that we should display an error on the documentation output but we could provide an option to the documentation writer like this :

{
  "openApi" : 
     {
        "openApiUrl": "https://thegardener.kelkoogroup.com/api/docs/swagger.json",
        "openApiType": "model",
        "ref": "#/definitions/Project",
        "deep": 1,
        "errorMessage" : "The service in unstable, the model is not available for the moment"
     }
}

"errorMessage" would be optional and displayed if the resource is not reachable. If not provided, no message displayed

In long term, I'm more in favour to register the error in the database and give an access to it though an API but it's bigger story.

@loriepisicchio what do you think ?