akka/akka-http

Parameters directive (and maybe also formFields?) should (optionally?) report all malformed fields

Open

#1.490 geöffnet am 24. Okt. 2017

Auf GitHub ansehen
 (5 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Scala (598 Forks)batch import
1 - triagedhelp wantedt:routing

Repository-Metriken

Stars
 (1.311 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 1T 10h) (2 gemergte PRs in 30 T)

Beschreibung

I have (OData) query params defined in my route like so:

parameters(('$top.as[Int].?, '$skip.as[Int].?)) { (top, skip) =>

I have the following rejection handler to handle all invalid parameters (handleAll):

RejectionHandler.newBuilder()
  .handleAll[MalformedQueryParamRejection] { paramRejections =>
    // paramRejections is a Seq[MalformedQueryParamRejection]
    ...
  }

The problem is that when called with the following

some-endpoint?$top=invalid&$skip=invalid

The paramRejections in the rejection handler has 2 entries, both for $top, instead of one for $top and one for $skip.

Seems related to the dollar sign on the params, since when I remove this things work as expected. Is this a known issue or is there a workaround available (that doesn't include removing the dollar sign; clients should be allowed to use dollar sign, as per OData standards odata.org/documentation/odata-version-2-0/uri-conventions)

Note, it seems its only the RejectionHandler that has a problem with multiple params starting with the dollar sign, since this line in the route correctly assigns top and skip to the variables when $top and $skip are supplied with valid values in the URI:

parameters(('$top.as[Int].?, '$skip.as[Int].?)) { (top, skip) =>

Contributor Guide