Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better error message on too-large chunked response [risk: low] #686

Merged
merged 2 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,10 @@ object FireCloudConfig {
val entityWorkspaceName: Option[String] = if (metrics.hasPath("entityWorkspaceName")) Some(metrics.getString("entityWorkspaceName")) else None
val libraryNamespaces: List[String] = metrics.getStringList("libraryWorkspaceNamespace").asScala.toList
}

object Spray {
private val spray = config.getConfig("spray")
// grab a copy of this Spray setting to use when displaying an error message
lazy val chunkLimit = spray.getString("can.client.response-chunk-aggregation-limit")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ object HttpClient {

case class PerformExternalRequest(requestCompression: Boolean, request: HttpRequest)

lazy val chunkLimitDisplay = FireCloudConfig.Spray.chunkLimit
.replace("m", "MB")
.replace("k", "KB")


def props(requestContext: RequestContext): Props = Props(new HttpClient(requestContext))

def createJsonHttpEntity(json: String) = {
Expand Down Expand Up @@ -63,8 +68,14 @@ class HttpClient (requestContext: RequestContext) extends Actor
case Success(response) =>
log.debug("Got response: " + response)
context.parent ! RequestComplete(response)
case Failure(re:RuntimeException) if re.getMessage.startsWith("sendReceive doesn't support chunked responses") =>
val message = s"The response payload was over ${HttpClient.chunkLimitDisplay} and cannot be processed. " +
s"Original request url: ${externalRequest.uri.toString}"
val customException = new FireCloudException(message, re)
log.error(message, customException)
context.parent ! RequestCompleteWithErrorReport(InternalServerError, message, customException)
case Failure(error) =>
val message = s"External request failed to ${externalRequest.uri.toString()}"
val message = s"External request failed to ${externalRequest.uri.toString()} - ${error.getMessage}"
val customException = new FireCloudException(message, error)

log.error(message, customException)
Expand Down