@@ -72,7 +72,9 @@ public Result compareValidationRuns(
7272 String sourceUrl = sourceUrlContainer .getUrlForSourceId (sourceId );
7373
7474 Path referenceReportPath = file .toPath ().resolve (args .getReferenceValidationReportName ());
75+ Path referenceErrorsPath = file .toPath ().resolve (args .getReferenceSystemErrorsName ());
7576 Path latestReportPath = file .toPath ().resolve (args .getLatestValidationReportName ());
77+ Path latestErrorsPath = file .toPath ().resolve (args .getLatestSystemErrorsName ());
7678 // in case a validation report does not exist for a sourceId we add the sourceId to
7779 // the list of corrupted sources
7880 if (!(referenceReportPath .toFile ().exists () && latestReportPath .toFile ().exists ())) {
@@ -86,22 +88,31 @@ public Result compareValidationRuns(
8688 }
8789 ValidationReport referenceReport ;
8890 ValidationReport latestReport ;
89- try {
90- referenceReport = ValidationReport .fromPath (referenceReportPath );
91- } catch (IOException ioException ) {
92- logger .atSevere ().withCause (ioException ).log ("Error reading reference validation report" );
91+ referenceReport = getValidationReport (referenceReportPath );
92+ if (referenceReport == null ) {
9393 // in case a file is corrupted, add the sourceId to the list of corrupted sources
9494 corruptedSources .addCorruptedSource (sourceId , true , false , true , null );
9595 continue ;
9696 }
97- try {
98- latestReport = ValidationReport .fromPath (latestReportPath );
99- } catch (IOException ioException ) {
100- logger .atSevere ().withCause (ioException ).log ("Error reading latest validation report" );
97+ latestReport = getValidationReport (latestReportPath );
98+ if (latestReport == null ) {
10199 // in case a file is corrupted, add the sourceId to the list of corrupted sources
102- corruptedSources .addCorruptedSource (sourceId , true , true , true , false );
100+ corruptedSources .addCorruptedSource (sourceId , true , false , true , null );
101+ continue ;
102+ }
103+
104+ // As an edge case, when the execution raise a system exception the report will contain
105+ // no notices but system notices are found in the system_errors.json file.
106+ // In this case, the system notices are not considered as corrupted sources.
107+ if (hasSystemErrors (referenceReport , referenceErrorsPath )) {
108+ corruptedSources .addCorruptedSource (sourceId , true , true , true , true );
109+ continue ;
110+ }
111+ if (hasSystemErrors (latestReport , latestErrorsPath )) {
112+ corruptedSources .addCorruptedSource (sourceId , true , true , true , true );
103113 continue ;
104114 }
115+
105116 newErrors .compareValidationReports (sourceId , sourceUrl , referenceReport , latestReport );
106117 droppedErrors .compareValidationReports (sourceId , sourceUrl , latestReport , referenceReport );
107118 newWarnings .compareValidationReports (sourceId , sourceUrl , referenceReport , latestReport );
@@ -140,6 +151,25 @@ public Result compareValidationRuns(
140151 return Result .create (report , reportSummaryString , failure );
141152 }
142153
154+ private boolean hasSystemErrors (ValidationReport validationReport , Path path ) {
155+ var systemErrors = getValidationReport (path );
156+ return validationReport .getNotices ().isEmpty ()
157+ && systemErrors != null
158+ && !systemErrors .getNotices ().isEmpty ();
159+ }
160+
161+ private static ValidationReport getValidationReport (Path referenceReportPath ) {
162+ ValidationReport referenceReport ;
163+ try {
164+ referenceReport = ValidationReport .fromPath (referenceReportPath );
165+ } catch (IOException ioException ) {
166+ logger .atSevere ().withCause (ioException ).log (
167+ "Error reading %s validation report" , referenceReportPath );
168+ return null ;
169+ }
170+ return referenceReport ;
171+ }
172+
143173 @ AutoValue
144174 abstract static class Result {
145175
0 commit comments