diff --git a/tdrs-backend/tdpservice/parsers/parse.py b/tdrs-backend/tdpservice/parsers/parse.py index 409d239b8..05c3da3ca 100644 --- a/tdrs-backend/tdpservice/parsers/parse.py +++ b/tdrs-backend/tdpservice/parsers/parse.py @@ -20,7 +20,7 @@ def parse_datafile(datafile): header_line = rawfile.readline().decode().strip() header, header_is_valid, header_errors = schema_defs.header.parse_and_validate( header_line, - util.make_generate_parser_error(datafile, 1) + util.make_generate_file_precheck_parser_error(datafile, 1) ) if not header_is_valid: logger.info(f"Preparser Error: {len(header_errors)} header errors encountered.") diff --git a/tdrs-backend/tdpservice/parsers/util.py b/tdrs-backend/tdpservice/parsers/util.py index a7b818297..08f4c61b3 100644 --- a/tdrs-backend/tdpservice/parsers/util.py +++ b/tdrs-backend/tdpservice/parsers/util.py @@ -64,6 +64,21 @@ def generate(schema, error_category, error_message, record=None, field=None): return generate +def make_generate_file_precheck_parser_error(datafile, line_number): + def generate(schema, error_category, error_message, record=None, field=None): + return generate_parser_error( + datafile=datafile, + line_number=line_number, + schema=schema, + error_category=error_category, + error_message=error_message, + record=record, + field=None, # purposely overridden to force a "Rejected" status for certain file precheck errors + ) + + return generate + + class SchemaManager: """Manages one or more RowSchema's and runs all parsers and validators."""