Issue (or bug) with mapper snap

Hello,
I have found something like bug. I cannot understand the strange result of the following pipeline.


When I run validation of this pipeline, I see following results.
As expected count of the input documents in the Gate output equal zero. You can see it on the screenshot below.

Following screenshot shows the settings of the mapper “Log File Not Found”:

If open Exression builder then you can see expression (as showed on the screenshot below). Window “Output Preview” contain expected result “File Not Found” (because count = 0).

However, result of this mapper contain value “File exists” (as showed on the screenshot below).

As a result the whole pipeline works incorrect during execution process.

Could somebody help me to sort out with this strange behavior of the Mapper snap?

I am attaching my pipeline.
SnapLogic_Bug_Gate_Count_reproduce_2022_01_11.slp (9.8 KB)

Thanks

Hey @Vladyslav,

I guess it’s working when you have documents on input. If not, the default configuration of Gate returns an empty object, so maybe that’s why there’s a conflict here.

But, I don’t see any reason why not to improvise, and use a Gate and a Mapper. Check the pipeline attached:

SnapLogic_Bug_Gate_Count1.slp (6.1 KB)

You can easily test by disconnecting and disabling the JSON Generator snap.

I hope you’ll find this helpful,
Bojan

Hi @bojanvelevski ,
Unfortunately your pipeline works in correct way only for cases where Gate don’t have any input snaps. I modified your pipeline by adding Filter between JSON Generator and Gate (
SnapLogic_Bug_Gate_Count_reproduce_alternative_2022_01_11.slp (7.3 KB)
). Filter snap don’t return any documents (I did it specially). In this case you will see result “File exists”.

But I need calculate count of input documents. And if this count equal zero then I am expecting to have “File not found” as a result.

Anyway, thank you for your help.

@Vladyslav, I agree, this appears to be a bug. The $input0.count value type doesn’t appear to be comparable type to 0. I suggest you open a ticket to support.

In the meantime, I think I found this expression to work for your case:
$input0.count.toString() == "0" ? "File Not Found" : "File exists"

Another hack is to place a JSON Formatter + JSON Parser between the Gate and Mapper. That seems to correct the expected type.

Yes, I can confirm that this is a bug in the Gate snap. The type of the count is actually AtomicInteger, and this isn’t comparable in the normal way with “== 0” in the expression language. The Gate snap should be fixed so that the count is the usual type for integers (BigInteger).

I’ll second Del’s workaround for the mapper expression.

I’ll take care of tracking and fixing this bug.

Thank you, @del and @ptaylor !