cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Issue (or bug) with mapper snap

Vladyslav
New Contributor

Hello,
I have found something like bug. I cannot understand the strange result of the following pipeline.
image
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.
image
Following screenshot shows the settings of the mapper โ€œLog File Not Foundโ€:
image
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).
image
However, result of this mapper contain value โ€œFile existsโ€ (as showed on the screenshot below).
image
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

5 REPLIES 5

bojanvelevski
Valued Contributor

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

Vladyslav
New Contributor

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โ€.
image

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.

del
Contributor III

@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.
image

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.