Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-32214

Throw an error if a String is used to query a Long/Integer field

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2021.0
    • Fix Version/s: 2021.50, 2023.8
    • Component/s: Core
    • Release Notes Summary:
      The "nuxeo.primitive.type.strict.validation" nuxeo.conf property allows to throw an error when decoding a string input as a number (integer, long, float, double).
    • Backlog priority:
      650
    • Upgrade notes:
      Hide

      Added the nuxeo.primitive.type.strict.validation Framework property.

      By default it is set to false, keeping the previous behavior: at low level, when trying to decode a string input as a number, fall back on 0 if the string cannot be decoded as a number, e.g. "foo".

      If set to true, in such case, a NumberFormatException is thrown.

      Consequently, when executing a REST API search request on a PageProvider and passing "foo" as a query parameter for a predicate on an integer field, the server will respond with a 400 Bad Request status code, e.g.:

      curl -u ******:******r -X GET http://localhost:8080/nuxeo/api/v1/search/pp/test_primitive_type_predicates/execute?integerField=foo | jq
      {
        "entity-type": "exception",
        "status": 400,
        "message": "java.lang.NumberFormatException: For input string: \"foo\""
      }
      
      Show
      Added the nuxeo.primitive.type.strict.validation Framework property. By default it is set to false , keeping the previous behavior: at low level, when trying to decode a string input as a number, fall back on 0 if the string cannot be decoded as a number, e.g. "foo". If set to true , in such case, a NumberFormatException is thrown. Consequently, when executing a REST API search request on a PageProvider and passing "foo" as a query parameter for a predicate on an integer field, the server will respond with a 400 Bad Request status code, e.g.: curl -u ******:******r -X GET http://localhost:8080/nuxeo/api/v1/search/pp/test_primitive_type_predicates/execute?integerField=foo | jq { "entity-type": "exception", "status": 400, "message": "java.lang.NumberFormatException: For input string: \"foo\"" }
    • Sprint:
      nxplatform #105, nxplatform #106
    • Story Points:
      5

      Description

      Pre-requisite : define a document type with an Integer field, create some documents where this field will have different values (0, 1 and 2 for example) and define a folder view with a quick filter for this Integer field

       

      Steps to reproduce:

      1. navigate to the Folder with some of the new documents
      2. observe that the Integer column contains various values
      3. set the quick filter with the value 1
      4. observe that only the documents where the Integer field value is 1 are returned
      5. now set the quick filter with the value foo
      6. observe that the documents where the Integer field value is 0 are returned <= this is the bug

       

      Expected behavior: an error is returned to indicate that the search term is not correct

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: