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

Boolean property set to a random string value using the document REST API should throw an exception

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2021.0, 2023.0
    • Fix Version/s: 2025.x, 2021.58, 2023.16
    • Component/s: Rest API
    • Release Notes Summary:
      The "nuxeo.primitive.type.strict.validation" nuxeo.conf property allows to throw an error when decoding a string input as a boolean.
    • Release Notes Description:
      Hide

      Boolean primitive type validation now relies on the nuxeo.primitive.type.strict.validation Framework property.

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

      If set to true, in such case, an IllegalArgumentException is thrown.

      Consequently, when executing a REST API:

      • search request on a PageProvider and passing "foo" as a query parameter for a predicate on a boolean field
        or
      • create a document request and "foo" as a value for a boolean property

      the server will respond with a 400 Bad Request status code

      Show
      Boolean primitive type validation now relies on the nuxeo.primitive.type.strict.validation Framework property. By default, it is set to false , keeping the previous behavior: at a low level, when trying to decode a string input as a boolean, fall back on 0 if the string cannot be decoded as a boolean, e.g. "foo". If set to true , in such case, an IllegalArgumentException is thrown. Consequently, when executing a REST API: search request on a PageProvider and passing "foo" as a query parameter for a predicate on a boolean field or create a document request and "foo" as a value for a boolean property the server will respond with a 400 Bad Request status code
    • Backlog priority:
      800
    • Sprint:
      nxplatform #116, nxplatform #117
    • Story Points:
      5

      Description

      When a custom property of type Boolean is set in Studio Modeler with a True default value, this default should be used when a string other than "false" or "true" (whatever the case is) is provided when creating a document.

      How to reproduce:

      • In Studio Modeler, define a document type with a property of type Boolean and a default value set to true
      • deploy to a Nuxeo instance
      • using the Document REST API, create a document of type defined above, setting the boolean property to a random string:
        curl -su Administrator:Administrator -XPOST \
        -H "properties:*" -H 'Content-Type:application/json' \
        -H 'accept: text/plain,application/json' \
        http://localhost:8080/nuxeo/api/v1/repo/default/path/default-domain/workspaces/myworkspace \
        -d '{ "entity-type": "document", "name": "MyDocType","type": "document-1", "properties": { "dc:title": "document-1", "mydoctype:booleanprop":"aaaaaaa" } }'
        

      Expected result: an exception is thrown because the entered value does not match the property type.
      Actual result: the document is created with the boolean property set to false

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: