Repository navigation
Keep every check and check-error when validate_start reports problems - #1867
Open
ericdelorefice wants to merge 1 commit into
Open
ericdelorefice wants to merge 1 commit into
ericdelorefice wants to merge 1 commit into
Conversation
…ds problems Resource.validate deleted from the checks list while enumerating it, so a check that yields two check-errors removed the next check too (or raised IndexError when it was last), and a check that followed a removed one never had its validate_start run. Collect the failing indexes first and filter afterwards, as frictionlessdata#1389 did for v4.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Resource.validate()removes a misconfigured check withdel checks[index]insidefor index, check in enumerate(checks). It does this once percheck-errorthe check yields, while still enumerating the list. So:validate()raiseIndexError: list assignment index out of range(the error reported in Exception generating Task Error occurs when validating a resource applying custum checks with wrong column's name related to these custom checks (using schema_sync) #1361),validate_start()run, so its own check-error is not reported.#1389 by @shashigharti fixed the #1361 crash on the v4 branch by collecting the indexes first; the v5 loop still deletes inside the loop.
Reproduction
Reproduced with frictionless 5.21.0 from PyPI and on main (c08fa29), using built-in checks and inline data; nothing is mocked.
Change
Collect the indexes of checks that yield a check-error, and filter the list once the loop is done (the same approach as #1389). A failed check is still removed and still gets no
validate_row()orvalidate_end()calls.Intended behaviour change:
validate()returns a report instead of raising in the first case. The report now carries every check-error and the errors of checks that follow a failed one. Every check'svalidate_start()now runs; before, the check after a removed one was skipped.Testing
frictionless/resource/__spec__/test_validate.py. Three fail on main and pass with the fix (the IndexError, the dropped next check, the unreported second check-error). Two controls pass on both: one check-error followed by a valid check, and a custom check that confirms a failed check gets no row or end calls.pytest frictionless: 2047 passed, 292 skipped with the fix; 2042 passed, 292 skipped on main (Python 3.10; mysql, postgresql, spss and visidata extras not installed here).ruff check frictionlesspasses, andpyrightreports 0 errors on both changed files.