Uploaded image for project: 'Talend Component Kit'
  1. Talend Component Kit
  2. TCOMP-2260

Validations on nested attributes are check even if the object is ActiveIf==false

Apply templateInsert Lucidchart Diagram
    XMLWordPrintable

Details

    Description

      I have a configuration that has a complex object:

      • This complex object is conditioned with an @ActiveIf
      • It contains some nested properties
        • Some of nested properties have constraints like @Required or @Pattern
      • Nested properties constraint are checked even if the main object has its ActiveIf  not met (false)

      Here is a simplified example:

       

      class MyDatastore{
         @Option
         private String aString;
         @Option
         private boolean condConf;
        
         @Option
         @ActiveIf(target = "condConf", value = "true")
         private ComplexConf myComplexConf = new ComplexConf();
      ;
         public static class ComplexConf {
              @Option
              @Required
              @Pattern("^https?://.+$")
              private String url = "";
         }
      }                     
      

      If configure my connector with "condConf= false", so,  "myComplexConf" should not be set and "myComplexConf.url" could be let to "", its constraint @Required & @Pattern should be checked, but it is.

      After debugging, it seems the issue comes from there :

      https://github.com/Talend/component-runtime/blob/76a681717bbb9875f23ceaa64b81f7d65b71c39d/component-runtime-manager/src/main/java/org/talend/sdk/component/runtime/manager/reflect/visibility/PayloadMapper.java#L121

      Indeed, onObject() is called on 'myComplexConf', but in this method, we don't check if this object if visible or not (ActiveIf), and nested attributes are computed first by the call to unflatten() method.

       

      Salesforce Properties

        Case
        Case Origin
        Case Type
        Case Age
        00283827 Email 2

        Attachments

          1. image-2022-10-24-15-18-47-456.png
            image-2022-10-24-15-18-47-456.png
            86 kB
          2. image-2023-04-19-11-50-35-234.png
            image-2023-04-19-11-50-35-234.png
            112 kB
          3. result_2.png
            result_2.png
            50 kB
          4. result-1.png
            result-1.png
            51 kB
          5. TCOMP2260_example.tgz
            56 kB

          Issue Links

            Activity

              People

                yyin Yueyan Yin
                ypiel Yves Piel
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                  Created:
                  Updated: