-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Updating SFTPSensor to properly handle scenario where file is missing #51167
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
Conversation
|
cc: @RNHTTR, do you mind taking a look at this? |
|
@jroachgolf84 I think the try expect block around hook.isfile, can be removed, because the exception is not raised from that call. Also I would suggest to update the test case for missing file - because at the moment its behavior depends on the the OSError, that never gets actually raised |
This is not the case; airflow/providers/sftp/src/airflow/providers/sftp/hooks/sftp.py Lines 220 to 230 in 1439e1f
|
|
Can you be more specific? Are you talking about the existing test? |
|
For some reason I have been looking at tests for version 2.11 - the tests for 3.0.x are fine. My bad. Maybe should there be a test case, when you receive False from the hook.isfile instead of OSError as last thing I can think of. |
|
Test added! |
|
One more thing - does the newly added test fail against the code without the change applied? |
This has been validated. |
jason810496
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix, I left a small nit for the files_pattern case.
Co-authored-by: Ryan Hatter <25823361+RNHTTR@users.noreply.github.com>
…apache#51167) * Updating SFTPSensor to properly handle scenario where file is missing * Updating variable name to actual_files_present * Changing list element variable name * Adding unit-test to handle irregular files * Updated exception handling, testing logic * Updated exception handling, testing logic * Update providers/sftp/src/airflow/providers/sftp/sensors/sftp.py Co-authored-by: Ryan Hatter <25823361+RNHTTR@users.noreply.github.com> --------- Co-authored-by: Ryan Hatter <25823361+RNHTTR@users.noreply.github.com>
This PR aims to address the issue raised in #51151. When a file failed to exist on the SFTP site, the
SFTPSensorwas still returningTrue. This change checks if the file does in fact exist. If not, it returns an empty list, resulting in the Sensor returningFalseand another poke being executed.closes: #51151