moov-io / ach

ACH implements a reader, writer, and validator for Automated Clearing House (ACH) files. The HTTP server is available in a Docker image and the Go package is available.
https://moov-io.github.io/ach/
Apache License 2.0
459 stars 151 forks source link

NACHA validation not catching an edge case #1039

Closed bdeyerlyfsb closed 2 years ago

bdeyerlyfsb commented 2 years ago

Hello,

We have found one edge case where the NACHA validation doesn't catch issues with the file.

ACH files have a blocking factor of 10. ACH files are padded with lines of 9s, so that the number of lines in the file are a multiple of 10. If the line count is already divisible by 10, no extra padding is needed.

We have found files that only have < 10 records and some ACH file generators are not placing block of 9s under the last record.

Can this be easily added to the validation?

Thanks!

adamdecaf commented 2 years ago

Thanks @bdeyerlyfsb for the issue! Do you happen to have an example?

I don't think we wanted to error in this case because the file could still be processed. If you want an error when padding records are missing we could add an opt-in check, but it wouldn't be the default.

bdeyerlyfsb commented 2 years ago

Thanks @bdeyerlyfsb for the issue! Do you happen to have an example?

I don't think we wanted to error in this case because the file could still be processed. If you want an error when padding records are missing we could add an opt-in check, but it wouldn't be the default.

Thanks for the response. If there is an optional check for this scenario that would be much appreciated.

Unforantely I cannot share the ACH file in question as example. But I do have an example online.

image

Note: Padding record - in gray: ACH files need to be created in multiples of 10 records. In this sample, there are 9 records including the file header and footer noted in yellow. In this case, we needed to add one additional padding record (99999...) to make the file contain a multiple of 10 records. Therefore, an ACH may have anywhere from no padding (99999...) records up to 9 records.

adamdecaf commented 2 years ago

@bdeyerlyfsb I'm not going to add a validation option for this since files can be parsed with the library even if they don't have padding records. This library pads files properly, so there's not a fix needed on our side.

If you'd like to validate this then a simple lines % 10 == 0 check would work in your application.

Thanks for opening an issue and let us know if you run into other issues!