Skip to content

[BUG] PUT endpoint causes 400: Invalid value for: path parameter ? #4653

@TheBugYouCantFix

Description

@TheBugYouCantFix

Tapir version: 1.11.33

Scala version: 3.7.0

Describe the bug
Every time I am trying to access some of the tapir endpoints I get 400 with "Invalid value for: path parameter ?% " even though all the input data and endpoint definitions seem to be correct.

've tried debugging it with logs and it seems like the app doesn't even reach neither zServerSecuityLogic handler nor serverLogic, so apparenly it has something to do with how tapir parses these requests. Changing the input type to plainBody didn't help either, as well as changing the
Content-type" in the http request. I've also tried creating a simplified test endpoint like

val testEndpoint = securedEndpoint
  .put
  .in("test")
  .in(plainBody[String])
  .out(plainBody[String])
  .zServerSecurityLogic(AuthHandlers.authenticateUser)
  .serverLogic { userId => input =>
    ZIO.logInfo(s"Test input: $input") *>
    ZIO.succeed(s"Received: $input")
  }

and the funny part is that it also give the same 400 error unless we change its type to GET:

val testEndpoint = securedEndpoint
  .get
  .in("test")
  .in(plainBody[String])
  .out(plainBody[String])
  .zServerSecurityLogic(AuthHandlers.authenticateUser)
  .serverLogic { userId => input =>
    ZIO.logInfo(s"Test input: $input") *>
    ZIO.succeed(s"Received: $input")
  }

How to reproduce?

  1. Clone my project repo: https://github.com/TheBugYouCantFix/MovieListApp
  2. Create a db and set its name and password at src/main/scala/app/backend/data/DataSource.scala
  3. Run the project
  4. Open the swagger at http://localhost:8080/docs/#/
  5. Get a token from a /signup endpoint, authorize with it
  6. Try to make a call to /updateUsername or /updatePassword endpoints

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions