NetCore8583 icon indicating copy to clipboard operation
NetCore8583 copied to clipboard

Can't parse message if the field 125 is in parsing template while it's not in the message

Open codedius opened this issue 2 years ago • 1 comments

Hi @Tochemey !

Trying to use your lib with the UK FasterPayments (FPS) integration and there's might be an issue:

Message: 9804000001020000000089118000000000000000007 (Type 9804, ASCII, BCD bitmap)

FPS has their own implemetation of the ISO8583 and fields of the message above are:

  • 24, Numeric, Lenght 3 (n 3)
  • 31, LLVAR (ans..18)
  • 125, LLVAR (ans..60)

The problem with the 125 field that is conditional and it might be in the message (with the secondary bitmap) but might be not (therefore secondary bitmap is also absent). So the description of the lib says:

A message does not need to contain all the fields specified in a parsing template, but a parsing template must contain all the fields specified in the bitmap of a message, or the MessageFactory won't be able to parse it because it has no way of knowing how it should parse that field (and also all subsequent fields).

And it works perfectly with fields up to 64 even though they are not presented in the message. But once I have field 125 in my parsing template and it is not presented in the message AND secondary bitmap is not presented as well the parsing crashes with the message in my case:

System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index') Actual value was 124.'

If I remove 125 from parsing template, then it works.

What I want is be able to put any conditional fields in the parsing template regardless of bitmap they are belong and get correct message with posibility to check whether conditional fields parsed or not. Looks like the lib relies on the bitmaps presented, so If there are no field AND no bitmap it crashes.

Seems like it's MessageFactory.cs, Line 588: if (bs.Get(i - 1))

codedius avatar Dec 03 '21 08:12 codedius

@codedius Thanks for reporting this. At the moment I really don't have the bandwidth to look into this. I will be glad if you can open a PR to address it. Bear in mind that the fix should cater for a general use not for your use case. Thanks

Tochemey avatar Dec 03 '21 10:12 Tochemey

@codedius I will have to close this issue because there is no activity. Feel free to reopen it.

Tochemey avatar Nov 23 '22 21:11 Tochemey

@codedius I would like to know whether you have an opportunity to fix this. I am reopening the issue.

Tochemey avatar Sep 17 '23 17:09 Tochemey