From 6eda6eba27f7cd084d219f0500b9804bc599e47e Mon Sep 17 00:00:00 2001 From: Moritz Lintterer Date: Thu, 8 Dec 2022 13:40:57 +0100 Subject: [PATCH 1/2] fix: adding error log when body size does not equal the parsed body size --- build.sbt | 2 +- .../de/innfactory/smithy4play/SmithyPlayEndpoint.scala | 6 ++++++ smithy4playTest/conf/application.conf | 3 +-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index a7fa85d3..5325a7bd 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ import sbt.Compile import sbt.Keys.cleanFiles -val releaseVersion = sys.env.getOrElse("TAG", "0.2.3-BETA.3") +val releaseVersion = sys.env.getOrElse("TAG", "0.2.3-BETA.6") addCommandAlias("publishSmithy4Play", "smithy4play/publish") addCommandAlias("publishLocalSmithy4Play", "smithy4play/publishLocal") addCommandAlias("generateCoverage", "clean; coverage; test; coverageReport") diff --git a/smithy4play/src/main/scala/de/innfactory/smithy4play/SmithyPlayEndpoint.scala b/smithy4play/src/main/scala/de/innfactory/smithy4play/SmithyPlayEndpoint.scala index 62309eb7..b6414027 100644 --- a/smithy4play/src/main/scala/de/innfactory/smithy4play/SmithyPlayEndpoint.scala +++ b/smithy4play/src/main/scala/de/innfactory/smithy4play/SmithyPlayEndpoint.scala @@ -50,6 +50,12 @@ class SmithyPlayEndpoint[Alg[_[_, _, _, _, _]], F[_] <: ContextRoute[_], Op[ def handler(v1: RequestHeader): Handler = httpEndpoint.map { httpEp => Action.async(parse.raw) { implicit request => + + if(request.body.size > 0 && request.body.asBytes().isEmpty) { + logger.error("received body size does not equal the parsed body size. \n" + + "This is probably due to the body being too large and thus play is unable to parse.\n" + + "Try setting play.http.parser.maxMemoryBuffer in application.conf") + } val result: EitherT[Future, ContextRouteError, O] = for { pathParams <- getPathParams(v1, httpEp) metadata = getMetadata(pathParams, v1) diff --git a/smithy4playTest/conf/application.conf b/smithy4playTest/conf/application.conf index 9d7249de..298076a7 100644 --- a/smithy4playTest/conf/application.conf +++ b/smithy4playTest/conf/application.conf @@ -1,9 +1,8 @@ # https://www.playframework.com/documentation/latest/Configuration -play.http.parser.maxDiskBuffer = 100MB play.http.parser.maxMemoryBuffer=100MB -parsers.anyContent.maxLength = 100MB + play.filters.enabled = [] smithy4play.autoRoutePackage = "controller" From c524f3545a288d6c998434fe3adb9e43af1dfbee Mon Sep 17 00:00:00 2001 From: Moritz Lintterer Date: Thu, 8 Dec 2022 14:19:31 +0100 Subject: [PATCH 2/2] fix: scalafmt --- .../innfactory/smithy4play/SmithyPlayEndpoint.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/smithy4play/src/main/scala/de/innfactory/smithy4play/SmithyPlayEndpoint.scala b/smithy4play/src/main/scala/de/innfactory/smithy4play/SmithyPlayEndpoint.scala index b6414027..6fed751b 100644 --- a/smithy4play/src/main/scala/de/innfactory/smithy4play/SmithyPlayEndpoint.scala +++ b/smithy4play/src/main/scala/de/innfactory/smithy4play/SmithyPlayEndpoint.scala @@ -50,11 +50,12 @@ class SmithyPlayEndpoint[Alg[_[_, _, _, _, _]], F[_] <: ContextRoute[_], Op[ def handler(v1: RequestHeader): Handler = httpEndpoint.map { httpEp => Action.async(parse.raw) { implicit request => - - if(request.body.size > 0 && request.body.asBytes().isEmpty) { - logger.error("received body size does not equal the parsed body size. \n" + - "This is probably due to the body being too large and thus play is unable to parse.\n" + - "Try setting play.http.parser.maxMemoryBuffer in application.conf") + if (request.body.size > 0 && request.body.asBytes().isEmpty) { + logger.error( + "received body size does not equal the parsed body size. \n" + + "This is probably due to the body being too large and thus play is unable to parse.\n" + + "Try setting play.http.parser.maxMemoryBuffer in application.conf" + ) } val result: EitherT[Future, ContextRouteError, O] = for { pathParams <- getPathParams(v1, httpEp)