upb-uc4 / lagom-core

Repository for the micro service backend using lagom.
Apache License 2.0
6 stars 0 forks source link

Akka timeout on empty user POST #282

Closed bastihav closed 4 years ago

bastihav commented 4 years ago

Describe the bug Empty user results in akka timeout. Seems to be broken for all requests without a username.

To Reproduce

{
    "authUser": {
        "username": "",
        "password": "",
        "role": "Lecturer"
    },
    "lecturer": {
    "username": "",
    "role": "Lecturer",
    "address": {
        "street": "",
        "houseNumber": "",
        "zipCode": "",
        "city": "",
        "country": ""
    },
    "firstName": "",
    "lastName": "",
    "picture": "",
    "email": "",
    "birthDate": "",
    "phoneNumber": "",
    "freeText": "",
    "researchArea": ""
}
}
{
    "name": "akka.pattern.AskTimeoutException: Ask timed out on [EntityRef(EntityTypeKey[de.upb.cs.uc4.user.impl.commands.UserCommand](UniversityCredits4Users), )] after [5000 ms]. Message of type [de.upb.cs.uc4.user.impl.commands.GetUser]. A typical reason for `AskTimeoutException` is that the recipient actor didn't send a reply.",
    "detail": "akka.pattern.AskTimeoutException: Ask timed out on [EntityRef(EntityTypeKey[de.upb.cs.uc4.user.impl.commands.UserCommand](UniversityCredits4Users), )] after [5000 ms]. Message of type [de.upb.cs.uc4.user.impl.commands.GetUser]. A typical reason for `AskTimeoutException` is that the recipient actor didn't send a reply.\n\tat akka.pattern.PromiseActorRef$.$anonfun$defaultOnTimeout$1(AskSupport.scala:646)\n\tat akka.pattern.PromiseActorRef$.$anonfun$apply$1(AskSupport.scala:667)\n\tat akka.actor.Scheduler$$anon$7.run(Scheduler.scala:476)\n\tat scala.concurrent.ExecutionContext$parasitic$.execute(ExecutionContext.scala:164)\n\tat akka.actor.LightArrayRevolverScheduler$TaskHolder.executeTask(LightArrayRevolverScheduler.scala:355)\n\tat akka.actor.LightArrayRevolverScheduler$$anon$3.executeBucket$1(LightArrayRevolverScheduler.scala:306)\n\tat akka.actor.LightArrayRevolverScheduler$$anon$3.nextTick(LightArrayRevolverScheduler.scala:310)\n\tat akka.actor.LightArrayRevolverScheduler$$anon$3.run(LightArrayRevolverScheduler.scala:262)\n\tat java.lang.Thread.run(Thread.java:748)\n"
}

Expected behavior 422

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

david-buderus commented 4 years ago

This is a problem with the current API. Vue wants to have the duplicate error together with the validation errors.

The Problem is here (line 88 in UserServiceImpl)

ref.ask[Option[User]](replyTo => GetUser(replyTo)).flatMap {
        case Some(_) =>
          throw CustomException.Duplicate
        case None =>
          //Validate PostMessage
          val validationErrorsFuture = postMessageUser match {

The username is used before it get checked (and a empty username creates a time out).