Skip to content

UserItem.CSVImport.create_from_file: wrong file-extension check #1865

Description

@jacalata

Users.create_from_file (in users_endpoint.py) validates the file with "csv" not in filepath before parsing. That test:

  • accepts non-CSV files whose path merely contains the substring csv (e.g. report.csv.bak, mycsv.txt, /home/csvuser/data.json)
  • rejects valid files whose extension is uppercase (e.g. USERS.CSV)

Neither matches the error message ("Only csv files are accepted").

Fix would be Path(filepath).suffix.lower() == ".csv".

Note: create_from_file is already deprecated (emits DeprecationWarning and is being replaced by bulk_add). Two paths:

  1. Patch under the deprecation window so the last few callers get correct behavior until removal.
  2. Just delete the method when the deprecation window closes and don't touch it in the meantime.

Filed as follow-up to a review comment on PR #1812 (out of scope for that PR's refactor).

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