Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation errors are swallowed when skip_unchanged is enabled #1378

Closed
matthewhegarty opened this issue Jan 20, 2022 · 1 comment
Closed
Assignees
Labels

Comments

@matthewhegarty
Copy link
Contributor

matthewhegarty commented Jan 20, 2022

Describe the bug

If you set skip_unchanged = True, you are saying that any rows that have not changed wrt to the persisted instance should be skipped (this is reported in the import results).

If you import a field which will fail validation (e.g. a bad date format), then this correctly raises a ValidationError, this is also reported in the import results.

However, if you set skip_unchanged=True and you have a field with a bad date format, you do not see the ValidationError in the results, instead the row is marked as skipped.

This is a bug because:

  1. The ValidationError should be reported.
  2. The row should be marked as invalid not skipped (the incoming data is modified wrt to persisted data).

This occurs because the validate_instance() method is only called if skip_row() returns False.

To Reproduce

  1. Create a Resource with skip_unchanged=True
  2. Create an instance of an existing entity (e.g. Author)
  3. Import an invalid row to be updated.

Failing test case here.

Versions (please complete the following information):

  • Django Import Export: 2.7.1
  • Python 3.9
  • Django 4.0

Expected behavior

ValidationErrors should be reported in the result. Invalid rows should not be skipped.

@matthewhegarty
Copy link
Contributor Author

Fixed in release 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant