Skip to content

Commit

Permalink
log suppressed errors out-of-band (#16261)
Browse files Browse the repository at this point in the history
CHANGELOG_BEGIN
- [JSON API] Log errors suppressed during streaming of /v1/query and
  /v1/fetch results.
CHANGELOG_END
  • Loading branch information
S11001001 authored Feb 28, 2023
1 parent f859dac commit b718717
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down

0 comments on commit b718717

Please sign in to comment.