Release Automation

Expand all | Collapse all

Loop - old output in actions when it fails (e.g. xpath)

Jump to Best Answer
  • 1.  Loop - old output in actions when it fails (e.g. xpath)

    Posted 07-18-2016 04:04 AM

    Hi,

     

    just one question, if the following is by design or if it really is a bug.

     

    we have a loop in our flow, where we use a xpath to get some parameters from a file. for the first time we did run now into trouble with this setup, as it appears that the xpath action doesn't reset it's output when it fails.

     

    so, in the first iterations the parameter was set in the config file, but in later iterations there were configs where the param was empty (a valid setting) but the xpath output still was writing the previous, non empty, value to the local parameter.

     

    I really dislike this behavior, especially because it is not mentioned in the description, if this is by design.

     

    regards

    michael



  • 2.  Re: Loop - old output in actions when it fails (e.g. xpath)

    Posted 07-18-2016 04:48 AM

    HI Michael

    I am trying to understand your flow logic

    Do you use XML loop type or using the xpath action?

    When I use the execute xpath query on empty value the action failed

    This is my xml file


     

    For XML loop I used the following XML file

     

    And I couldn't see that the value of logs from second iteration (Warn) added as a value of the third iteration

    Will be useful to get more information to understand your problem

    Thanks

    Jacky



  • 3.  Re: Loop - old output in actions when it fails (e.g. xpath)

    Posted 07-18-2016 05:24 AM

    Hi Jacky,

     

    I'm using the xpath action in a foreach loop.

     

    If I find the time I can try to make a small flow to reproduce it.

     

    best regards

    michael



  • 4.  Re: Loop - old output in actions when it fails (e.g. xpath)

    Posted 07-18-2016 08:11 AM

    Hi Jacky,

     

    I'm using 5.5.2.191 for this:

     

    I have a folder with 4 xml files in it, the content is as follows:

    test1.xml

    <?xml version="1.0" encoding="utf-8"?>
    <ara>
     <envprefix>DEV</envprefix>
    </ara>
    

    test2.xml

    <?xml version="1.0" encoding="utf-8"?>
    <ara>
     <envprefix>ACT</envprefix>
    </ara>
    

    test3.xml

    <?xml version="1.0" encoding="utf-8"?>
    <ara>
     <envprefix>PROD</envprefix>
    </ara>
    

    test4.xml

    <?xml version="1.0" encoding="utf-8"?>
    <ara>
     <envprefix></envprefix>
    </ara>
    

     

    for the flow I have the following:

    XPathTest-1.png

    XPathTest-2.png

    XPathTest-3.png

     

    As you see, in the end I have the entry of test3.xml twice in my result, which means that the xpath action doesn't reset it's result when it doesn't find anything.

     

    best regards

    michael



  • 5.  Re: Loop - old output in actions when it fails (e.g. xpath)

    Posted 07-18-2016 08:24 AM

    Hi Michael

    In your xpath action "get envprefix" you cleared the failed on pause checkbox and the add value to array is executing even if the xpath action failed.

    If you set the link condition only on pass this probably will solve your problem.

    Let me know if this help

    Thanks

    Jacky



  • 6.  Re: Loop - old output in actions when it fails (e.g. xpath)

    Posted 07-18-2016 08:29 AM

    Hi Jacky,

     

    as I said, the envprefix is an optional parameter, so I need to remove the pause on failure flag, otherwise the action will hang.

     

    also the setup for the real flow is the same, where I need to continue with the next part, whether the xpath did found an envprefix or not, because it is optional.

     

    well, I now added a setting to an empty string, if the xpath fails, but I still want to know, if this is by design, that this action saves its last valid output instead of returning an empty string, when it fails.

     

    regards

    michael



  • 7.  Re: Loop - old output in actions when it fails (e.g. xpath)
    Best Answer

    Posted 07-18-2016 08:48 AM

    Since the action is failing the parameter that should hold the envprefix value will not be updated , this done once the action manage to find value to add , I guess this is how the action designed

    What you can do is to use the second output field of the xpath action "XML element count" and after this action finish compare the value to zero , if it is equal to zero this mean there is no elements .Next  you can decide how to proceed (I think you flow anyway should handle situation where the optional element doesn't have value so you just need to set the conditions between the compare action to the rest of the flow)



  • 8.  Re: Loop - old output in actions when it fails (e.g. xpath)

    Posted 07-18-2016 08:52 AM

    ok, so it is by design.

     

    which I really dislike, as it is also different from the usage of a xml loop, where you define a default value if a subquery doesn't return a result.

     

    but well, as I said, we have it already fixed in our flow, I just wanted to make sure, that it isn't a bug.

     

    you guys should maybe think about pointing this out in the action description, that you don't set the output to an empty string, if nothing is found.