Anthony-Nolan / Atlas

A free & open-source Donor Search Algorithm Service
GNU General Public License v3.0
9 stars 5 forks source link

Add file name to alert "Donor Ids file was present but it was empty" #1142

Closed zabeen closed 6 months ago

zabeen commented 9 months ago

Alert from CheckDonorIdsFromFile Donor Ids file was present but it was empty. at Atlas.DonorImport.Services.DonorChecker.LazilyParsingDonorIdFile.ReadLazyDonorIds()+MoveNext() in /home/vsts/work/1/s/Atlas.DonorImport/Services/DonorChecker/DonorIdCheckerFileParser.cs:line 41 at MoreLinq.MoreEnumerable.<>c__DisplayClass23_0`2.<g__Batch|2>d.MoveNext() at Atlas.DonorImport.Services.DonorChecker.DonorIdChecker.CheckDonorIdsFromFile(DonorIdCheckFile file) in /home/vsts/work/1/s/Atlas.DonorImport/Services/DonorChecker/DonorIdChecker.cs:line 57

Update:

SergeyEzh commented 8 months ago

@zabeen, as far I understood, currently exception is suppressed and only exception message is written to AI without stacktrace. Do you want keep it as is but extend AI trace message with stack trace OR make throw it upper to allow AI catch it and log an exception?

zabeen commented 8 months ago

@SergeyEzh As discussed over teams, stack trace isn't useful here as we know exactly what causes EmptyDonorFileException to be thrown (underlying file stream is null).

Further, I see three places in code where EmptyDonorFileException is being thrown and caught:

and in each case the stack trace is being written to the alert message without file name.

So I am extending this ticket to cover all these cases.

SergeyEzh commented 8 months ago

@zabeen, I was doing final testing before commit and now alert message is confusing me. Because it states that file was found but it is empty, though I found that this exception is thrown when I put wrong url to blob to service bus message. When I upload 'real' empty file to blob storage and put correct blob url in service bus it just reads empty file and throws no exception.

zabeen commented 8 months ago

@SergeyEzh In real usage, I have only seen this error where a file was dropped into blob storage, which caused an import request message to be published, and then user manually deleted the file from storage before the donor import app imported it. The blob stream generated by the function is null and then hits the "empty file" exception (which is really a "missing file").

I am surprised an actual empty file doesn't result in any exception though. Perhaps the check that throws the EmptyDonorFileException needs to be extended to stream is null or empty?

SergeyEzh commented 8 months ago

@zabeen, I would prefer two messages like 'Unable to read file content' in case stream is null and 'The file contains no data' in case no data parsed from stream, rather than checking stream length.

zabeen commented 8 months ago

I would prefer two messages like 'Unable to read file content' in case stream is null and 'The file contains no data' in case no data parsed from stream, rather than checking stream length.

@SergeyEzh I'll create a new ticket for that work, right now I want to close and deploy this ticket with the existing support enhancement.

zabeen commented 8 months ago

Testing Notes

Feature test

Repeat same test with:

Regression tests

DmitriyShcherbina commented 8 months ago

@zabeen Feature testing status: Ok

donor import alert donor ids Screenshot at Jan 09 14-41-26

Regression testing status: Ok

donor-import-success donor-id-checker-success donor_info_success