Skip to content

Commit

Permalink
make header precheck errors force rejected status
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimpe committed Oct 4, 2023
1 parent 5c62b11 commit 1c60985
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tdrs-backend/tdpservice/parsers/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
15 changes: 15 additions & 0 deletions tdrs-backend/tdpservice/parsers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down

0 comments on commit 1c60985

Please sign in to comment.