Skip to content

parse_export_format calls undefined validate_export_csv_rows, causing NameError and test failure #902

@manshusainishab

Description

@manshusainishab

Issue

What is the issue?

application/utils/spreadsheet_parsers.py:206 (function parse_export_format) calls validate_export_csv_rows(lfile), but no function by that name is defined or imported anywhere in the repository:

Found this when I was running tests for a sanity check before starting module B project.

$ git grep -n "validate_export_csv_rows"
application/utils/spreadsheet_parsers.py:206: validated_rows = validate_export_csv_rows(lfile)

Only one call site, no definition. A function with a near-identical name and matching signature/purpose does exist in the same file:

$ git grep -n "def validate_import_csv_rows"
application/utils/spreadsheet_parsers.py:138:def validate_import_csv_rows(rows: List[Dict[str, Any]]) -> List[Dict[str, Any]]:

The call was introduced by PR #683 ("refactor(csv-import): move CSV validation into spreadsheet parser", commit 4de782b), which extracted the validator under the _import_ name but left this single caller pointing at the old/intended _export_ name. It looks like a copy-paste typo from when the helper was renamed during the refactor.

Result: any code path that invokes parse_export_format raises NameError: name 'validate_export_csv_rows' is not defined. The unit test application/tests/spreadsheet_parsers_test.py::TestParsers::test_parse_export_format fails on this every run.

Expected Behaviour

parse_export_format should validate the input CSV rows via the existing validate_import_csv_rows helper and proceed to build the CRE/standard dictionaries. The corresponding unit test should pass.

Actual Behaviour

The call raises NameError:

File "application/utils/spreadsheet_parsers.py", line 206, in parse_export_format
validated_rows = validate_export_csv_rows(lfile)
NameError: name 'validate_export_csv_rows' is not defined

make test reports test_parse_export_format as ERROR.

Steps to reproduce

  1. Check out main at any commit since 4de782b.

  2. Activate the project venv.

  3. Run the targeted test:
    FLASK_APP=cre.py flask test application.tests.spreadsheet_parsers_test

  4. Observe ERROR: test_parse_export_format with the NameError traceback above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions