From b718717dec143eb2c789a3a94e20b2cc9afb6608 Mon Sep 17 00:00:00 2001 From: Stephen Compall Date: Tue, 28 Feb 2023 17:18:55 -0500 Subject: [PATCH] log suppressed errors out-of-band (#16261) CHANGELOG_BEGIN - [JSON API] Log errors suppressed during streaming of /v1/query and /v1/fetch results. CHANGELOG_END --- .../scala/com/digitalasset/http/Endpoints.scala | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ledger-service/http-json/src/main/scala/com/digitalasset/http/Endpoints.scala b/ledger-service/http-json/src/main/scala/com/digitalasset/http/Endpoints.scala index c6cdd87977b0..26fa0bb6fe54 100644 --- a/ledger-service/http-json/src/main/scala/com/digitalasset/http/Endpoints.scala +++ b/ledger-service/http-json/src/main/scala/com/digitalasset/http/Endpoints.scala @@ -322,7 +322,9 @@ class Endpoints( output.map(_.fold(httpResponseError, searchHttpResponse)) } - private def searchHttpResponse(searchResult: SearchResult[Error \/ JsValue]): HttpResponse = { + private def searchHttpResponse( + searchResult: SearchResult[Error \/ JsValue] + )(implicit lc: LoggingContextOf[RequestID]): HttpResponse = { import json.JsonProtocol._ val response: Source[ByteString, NotUsed] = searchResult match { @@ -341,9 +343,17 @@ class Endpoints( ) } - private[this] def filterStreamErrors[E, A]: Flow[Error \/ A, Error \/ A, NotUsed] = + private[this] def filterStreamErrors[A](implicit + lc: LoggingContextOf[RequestID] + ): Flow[Error \/ A, Error \/ A, NotUsed] = Flow[Error \/ A].map { - case -\/(ServerError(_)) => -\/(ServerError.fromMsg("internal server error")) + case -\/(ServerError(t)) => + val hideMsg = "internal server error" + logger.error( + s"hiding internal error details from response, responding '$hideMsg' instead", + t, + ) + -\/(ServerError.fromMsg(hideMsg)) case o => o }